servo: Merge #4155 - Verify that reftest passes valid servo args (from mttr:reftest_unknown_servo_args); r=jdm

Fixes #4101

Source-Repo: https://github.com/servo/servo
Source-Revision: c68269097e8b6dfd363a74dcf6c5d7de1f675cd9
This commit is contained in:
Matthew Rasmus 2014-12-02 17:51:50 -07:00
Родитель e495923e3f
Коммит 9a64aacad4
1 изменённых файлов: 23 добавлений и 2 удалений

Просмотреть файл

@ -17,7 +17,7 @@ extern crate url;
use std::ascii::AsciiExt;
use std::io;
use std::io::{File, Reader, Command};
use std::io::{File, Reader, Command, IoResult};
use std::io::process::ExitStatus;
use std::io::fs::PathExtensions;
use std::os;
@ -98,13 +98,34 @@ fn main() {
color: AutoColor
};
match run_tests_console(&test_opts, all_tests) {
match run(test_opts,
all_tests,
servo_args.iter().map(|x| x.clone()).collect()) {
Ok(false) => os::set_exit_status(1), // tests failed
Err(_) => os::set_exit_status(2), // I/O-related failure
_ => (),
}
}
fn run(test_opts: TestOpts, all_tests: Vec<TestDescAndFn>,
servo_args: Vec<String>) -> IoResult<bool> {
// Verify that we're passing in valid servo arguments. Otherwise, servo
// will exit before we've run any tests, and it will appear to us as if
// all the tests are failing.
let mut command = match Command::new("target/servo").args(servo_args.as_slice()).spawn() {
Ok(p) => p,
Err(e) => panic!("failed to execute process: {}", e),
};
let stderr = command.stderr.as_mut().unwrap().read_to_string().unwrap();
if stderr.as_slice().contains("Unrecognized") {
println!("Servo: {}", stderr.as_slice());
return Ok(false);
}
run_tests_console(&test_opts, all_tests)
}
#[deriving(PartialEq)]
enum ReftestKind {
Same,