mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Reftest harness walks directory and appends tests for all manifest files
it finds. This is a first step towards importing some of the css-wg reftests.
This commit is contained in:
parent
80c001b2f0
commit
ea3219e5d7
2 changed files with 28 additions and 10 deletions
|
@ -86,12 +86,12 @@ check-servo: $(foreach lib_crate,$(SERVO_LIB_CRATES),check-servo-$(lib_crate)) s
|
||||||
.PHONY: check-ref-cpu
|
.PHONY: check-ref-cpu
|
||||||
check-ref-cpu: reftest
|
check-ref-cpu: reftest
|
||||||
@$(call E, check: reftests with CPU rendering)
|
@$(call E, check: reftests with CPU rendering)
|
||||||
$(Q)./reftest cpu $(S)src/test/ref/basic.list $(TESTNAME)
|
$(Q)./reftest cpu $(S)src/test/ref $(TESTNAME)
|
||||||
|
|
||||||
.PHONY: check-ref-gpu
|
.PHONY: check-ref-gpu
|
||||||
check-ref-gpu: reftest
|
check-ref-gpu: reftest
|
||||||
@$(call E, check: reftests with GPU rendering)
|
@$(call E, check: reftests with GPU rendering)
|
||||||
$(Q)./reftest gpu $(S)src/test/ref/basic.list $(TESTNAME)
|
$(Q)./reftest gpu $(S)src/test/ref $(TESTNAME)
|
||||||
|
|
||||||
.PHONY: check-ref
|
.PHONY: check-ref
|
||||||
check-ref: check-ref-cpu check-ref-gpu
|
check-ref: check-ref-cpu check-ref-gpu
|
||||||
|
|
|
@ -12,6 +12,7 @@ extern crate std;
|
||||||
extern crate test;
|
extern crate test;
|
||||||
extern crate regex;
|
extern crate regex;
|
||||||
|
|
||||||
|
use std::ascii::StrAsciiExt;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::{File, Reader, Command};
|
use std::io::{File, Reader, Command};
|
||||||
use std::io::process::ExitStatus;
|
use std::io::process::ExitStatus;
|
||||||
|
@ -32,10 +33,10 @@ fn main() {
|
||||||
let harness_args = parts.next().unwrap(); // .split() is never empty
|
let harness_args = parts.next().unwrap(); // .split() is never empty
|
||||||
let servo_args = parts.next().unwrap_or(&[]);
|
let servo_args = parts.next().unwrap_or(&[]);
|
||||||
|
|
||||||
let (render_mode_string, manifest, testname) = match harness_args {
|
let (render_mode_string, base_path, testname) = match harness_args {
|
||||||
[] | [_] => fail!("USAGE: cpu|gpu manifest [testname regex]"),
|
[] | [_] => fail!("USAGE: cpu|gpu base_path [testname regex]"),
|
||||||
[ref render_mode_string, ref manifest] => (render_mode_string, manifest, None),
|
[ref render_mode_string, ref base_path] => (render_mode_string, base_path, None),
|
||||||
[ref render_mode_string, ref manifest, ref testname, ..] => (render_mode_string, manifest, Some(Regex::new(testname.as_slice()).unwrap())),
|
[ref render_mode_string, ref base_path, ref testname, ..] => (render_mode_string, base_path, Some(Regex::new(testname.as_slice()).unwrap())),
|
||||||
};
|
};
|
||||||
|
|
||||||
let render_mode = match render_mode_string.as_slice() {
|
let render_mode = match render_mode_string.as_slice() {
|
||||||
|
@ -44,7 +45,24 @@ fn main() {
|
||||||
_ => fail!("First argument must specify cpu or gpu as rendering mode")
|
_ => fail!("First argument must specify cpu or gpu as rendering mode")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let mut all_tests = vec!();
|
||||||
|
println!("Scanning {} for manifests\n", base_path);
|
||||||
|
|
||||||
|
for file in io::fs::walk_dir(&Path::new(base_path.as_slice())).unwrap() {
|
||||||
|
let maybe_extension = file.extension_str();
|
||||||
|
match maybe_extension {
|
||||||
|
Some(extension) => {
|
||||||
|
if extension.to_ascii_lower().as_slice() == "list" && file.is_file() {
|
||||||
|
let manifest = file.as_str().unwrap();
|
||||||
let tests = parse_lists(manifest, servo_args, render_mode);
|
let tests = parse_lists(manifest, servo_args, render_mode);
|
||||||
|
println!("\t{} [{} tests]", manifest, tests.len());
|
||||||
|
all_tests.push_all_move(tests);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let test_opts = TestOpts {
|
let test_opts = TestOpts {
|
||||||
filter: testname,
|
filter: testname,
|
||||||
run_ignored: false,
|
run_ignored: false,
|
||||||
|
@ -59,7 +77,7 @@ fn main() {
|
||||||
color: AutoColor
|
color: AutoColor
|
||||||
};
|
};
|
||||||
|
|
||||||
match run_tests_console(&test_opts, tests) {
|
match run_tests_console(&test_opts, all_tests) {
|
||||||
Ok(false) => os::set_exit_status(1), // tests failed
|
Ok(false) => os::set_exit_status(1), // tests failed
|
||||||
Err(_) => os::set_exit_status(2), // I/O-related failure
|
Err(_) => os::set_exit_status(2), // I/O-related failure
|
||||||
_ => (),
|
_ => (),
|
||||||
|
@ -89,10 +107,10 @@ struct TestLine<'a> {
|
||||||
file_right: &'a str,
|
file_right: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_lists(file: &String, servo_args: &[String], render_mode: RenderMode) -> Vec<TestDescAndFn> {
|
fn parse_lists(file: &str, servo_args: &[String], render_mode: RenderMode) -> Vec<TestDescAndFn> {
|
||||||
let mut tests = Vec::new();
|
let mut tests = Vec::new();
|
||||||
let mut next_id = 0;
|
let mut next_id = 0;
|
||||||
let file_path = Path::new(file.clone());
|
let file_path = Path::new(file);
|
||||||
let contents = File::open_mode(&file_path, io::Open, io::Read)
|
let contents = File::open_mode(&file_path, io::Open, io::Read)
|
||||||
.and_then(|mut f| f.read_to_string())
|
.and_then(|mut f| f.read_to_string())
|
||||||
.ok().expect("Could not read file");
|
.ok().expect("Could not read file");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue