auto merge of #5418 : Ms2ger/servo/contenttest, r=jdm

This commit is contained in:
bors-servo 2015-03-28 09:37:06 -06:00
commit 65a0ebc567

View file

@ -8,9 +8,7 @@
// except according to those terms.
#![feature(collections)]
#![feature(core)]
#![feature(exit_status)]
#![feature(old_io)]
#![feature(path)]
#![feature(rustc_private)]
#![feature(std_misc)]
@ -25,8 +23,7 @@ use getopts::{getopts, reqopt};
use std::{str, env};
use std::ffi::OsStr;
use std::fs::read_dir;
use std::old_io::Reader;
use std::old_io::process::{Command, Ignored, CreatePipe, InheritFd, ExitStatus};
use std::process::{Command, Stdio};
use std::thunk::Thunk;
#[derive(Clone)]
@ -50,9 +47,9 @@ fn main() {
fn parse_config(args: Vec<String>) -> Config {
let args = args.tail();
let opts = vec!(reqopt("s", "source-dir", "source-dir", "source-dir"));
let matches = match getopts(args, opts.as_slice()) {
Ok(m) => m,
Err(f) => panic!(f.to_string())
let matches = match getopts(args, &opts) {
Ok(m) => m,
Err(f) => panic!(f.to_string())
};
Config {
@ -99,38 +96,26 @@ fn run_test(file: String) {
let path = env::current_dir().unwrap().join(&file);
// FIXME (#1094): not the right way to transform a path
let infile = format!("file://{}", path.display());
let stdout = CreatePipe(false, true);
let stderr = InheritFd(2);
let args = ["-z", "-f", infile.as_slice()];
let args = ["-z", "-f", &*infile];
let mut prc_arg = env::current_exe().unwrap();
let prc_arg = match prc_arg.pop() {
true => prc_arg.join("servo"),
_ => panic!("could not pop directory"),
};
let mut prc = match Command::new(prc_arg.to_str().unwrap())
.args(args.as_slice())
.stdin(Ignored)
.stdout(stdout)
.stderr(stderr)
.spawn()
let output = match Command::new(prc_arg.to_str().unwrap())
.args(&args)
.stdin(Stdio::null())
.stderr(Stdio::inherit())
.output()
{
Ok(p) => p,
_ => panic!("Unable to spawn process."),
};
let mut output = Vec::new();
loop {
let byte = prc.stdout.as_mut().unwrap().read_byte();
match byte {
Ok(byte) => {
print!("{}", byte as char);
output.push(byte);
}
_ => break
}
}
let out = str::from_utf8(output.as_slice());
print!("{}", str::from_utf8(&output.stdout).unwrap());
let out = str::from_utf8(&output.stderr);
let lines: Vec<&str> = out.unwrap().split('\n').collect();
for &line in lines.iter() {
if line.contains("TEST-UNEXPECTED-FAIL") {
@ -138,8 +123,7 @@ fn run_test(file: String) {
}
}
let retval = prc.wait();
if retval != Ok(ExitStatus(0)) {
panic!("Servo exited with non-zero status {:?}", retval);
if !output.status.success() {
panic!("Servo exited with non-zero status {:?}", output.status);
}
}