mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
taking into account TESTNAME variable in reftest (see #41)
This commit is contained in:
parent
1e263f9dec
commit
e9343e4bbc
2 changed files with 49 additions and 47 deletions
|
@ -82,12 +82,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 $(S)src/test/ref/*.list -- -c
|
$(Q)./reftest $(S)src/test/ref/basic.list $(TESTNAME) -- -c
|
||||||
|
|
||||||
.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 $(S)src/test/ref/*.list
|
$(Q)./reftest $(S)src/test/ref/basic.list $(TESTNAME)
|
||||||
|
|
||||||
.PHONY: check-ref
|
.PHONY: check-ref
|
||||||
check-ref: check-ref-cpu check-ref-gpu
|
check-ref: check-ref-cpu check-ref-gpu
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
extern crate png;
|
extern crate png;
|
||||||
extern crate std;
|
extern crate std;
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
extern crate regex;
|
||||||
|
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::{File, Reader, Command};
|
use std::io::{File, Reader, Command};
|
||||||
|
@ -17,21 +18,24 @@ use std::io::process::ExitStatus;
|
||||||
use std::os;
|
use std::os;
|
||||||
use test::{DynTestName, DynTestFn, TestDesc, TestOpts, TestDescAndFn};
|
use test::{DynTestName, DynTestFn, TestDesc, TestOpts, TestDescAndFn};
|
||||||
use test::run_tests_console;
|
use test::run_tests_console;
|
||||||
|
use regex::Regex;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args = os::args();
|
let args = os::args();
|
||||||
let mut parts = args.tail().split(|e| "--" == e.as_slice());
|
let mut parts = args.tail().split(|e| "--" == e.as_slice());
|
||||||
|
|
||||||
let files = 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(&[]);
|
||||||
|
|
||||||
if files.len() == 0 {
|
let (manifest, testname) = match harness_args {
|
||||||
fail!("error: at least one reftest list must be given");
|
[] => fail!("error: at least one reftest list must be given"),
|
||||||
}
|
[ref manifest] => (manifest, None),
|
||||||
|
[ref manifest, ref testname, ..] => (manifest, Some(Regex::new(testname.as_slice()).unwrap())),
|
||||||
|
};
|
||||||
|
|
||||||
let tests = parse_lists(files, servo_args);
|
let tests = parse_lists(manifest, servo_args);
|
||||||
let test_opts = TestOpts {
|
let test_opts = TestOpts {
|
||||||
filter: None,
|
filter: testname,
|
||||||
run_ignored: false,
|
run_ignored: false,
|
||||||
logfile: None,
|
logfile: None,
|
||||||
run_tests: true,
|
run_tests: true,
|
||||||
|
@ -64,54 +68,52 @@ struct Reftest {
|
||||||
servo_args: Vec<String>,
|
servo_args: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_lists(filenames: &[String], servo_args: &[String]) -> Vec<TestDescAndFn> {
|
fn parse_lists(file: &String, servo_args: &[String]) -> Vec<TestDescAndFn> {
|
||||||
let mut tests = Vec::new();
|
let mut tests = Vec::new();
|
||||||
let mut next_id = 0;
|
let mut next_id = 0;
|
||||||
for file in filenames.iter() {
|
let file_path = Path::new(file.clone());
|
||||||
let file_path = Path::new(file.clone());
|
let contents = match File::open_mode(&file_path, io::Open, io::Read)
|
||||||
let contents = match File::open_mode(&file_path, io::Open, io::Read)
|
.and_then(|mut f| {
|
||||||
.and_then(|mut f| {
|
f.read_to_str()
|
||||||
f.read_to_str()
|
}) {
|
||||||
}) {
|
Ok(s) => s,
|
||||||
Ok(s) => s,
|
_ => fail!("Could not read file"),
|
||||||
_ => fail!("Could not read file"),
|
};
|
||||||
};
|
|
||||||
|
|
||||||
for line in contents.as_slice().lines() {
|
for line in contents.as_slice().lines() {
|
||||||
// ignore comments
|
// ignore comments
|
||||||
if line.starts_with("#") {
|
if line.starts_with("#") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let parts: Vec<&str> = line.split(' ').filter(|p| !p.is_empty()).collect();
|
let parts: Vec<&str> = line.split(' ').filter(|p| !p.is_empty()).collect();
|
||||||
|
|
||||||
if parts.len() != 3 {
|
if parts.len() != 3 {
|
||||||
fail!("reftest line: '{:s}' doesn't match 'KIND LEFT RIGHT'", line);
|
fail!("reftest line: '{:s}' doesn't match 'KIND LEFT RIGHT'", line);
|
||||||
}
|
}
|
||||||
|
|
||||||
let kind = match parts.get(0) {
|
let kind = match parts.get(0) {
|
||||||
& "==" => Same,
|
& "==" => Same,
|
||||||
& "!=" => Different,
|
& "!=" => Different,
|
||||||
&part => fail!("reftest line: '{:s}' has invalid kind '{:s}'",
|
&part => fail!("reftest line: '{:s}' has invalid kind '{:s}'",
|
||||||
line, part)
|
line, part)
|
||||||
};
|
};
|
||||||
let src_path = file_path.dir_path();
|
let src_path = file_path.dir_path();
|
||||||
let src_dir = src_path.display().to_str();
|
let src_dir = src_path.display().to_str();
|
||||||
let file_left = src_dir.clone().append("/").append(*parts.get(1));
|
let file_left = src_dir.clone().append("/").append(*parts.get(1));
|
||||||
let file_right = src_dir.append("/").append(*parts.get(2));
|
let file_right = src_dir.append("/").append(*parts.get(2));
|
||||||
|
|
||||||
let reftest = Reftest {
|
let reftest = Reftest {
|
||||||
name: parts.get(1).to_string().append(" / ").append(*parts.get(2)),
|
name: parts.get(1).to_string().append(" / ").append(*parts.get(2)),
|
||||||
kind: kind,
|
kind: kind,
|
||||||
files: [file_left, file_right],
|
files: [file_left, file_right],
|
||||||
id: next_id,
|
id: next_id,
|
||||||
servo_args: servo_args.iter().map(|x| x.clone()).collect(),
|
servo_args: servo_args.iter().map(|x| x.clone()).collect(),
|
||||||
};
|
};
|
||||||
|
|
||||||
next_id += 1;
|
next_id += 1;
|
||||||
|
|
||||||
tests.push(make_test(reftest));
|
tests.push(make_test(reftest));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
tests
|
tests
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue