From 6b0bf4cf0a5e9d454240df80b60b731cb6978d21 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 27 Mar 2015 21:09:28 +0100 Subject: [PATCH 1/3] Move contenttest to the new process APIs. --- tests/contenttest.rs | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/tests/contenttest.rs b/tests/contenttest.rs index 3723bd30ee0..e8b281cf7a2 100644 --- a/tests/contenttest.rs +++ b/tests/contenttest.rs @@ -10,7 +10,6 @@ #![feature(collections)] #![feature(core)] #![feature(exit_status)] -#![feature(old_io)] #![feature(path)] #![feature(rustc_private)] #![feature(std_misc)] @@ -25,8 +24,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)] @@ -99,8 +97,6 @@ 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 mut prc_arg = env::current_exe().unwrap(); @@ -108,29 +104,19 @@ fn run_test(file: String) { true => prc_arg.join("servo"), _ => panic!("could not pop directory"), }; - let mut prc = match Command::new(prc_arg.to_str().unwrap()) + let output = match Command::new(prc_arg.to_str().unwrap()) .args(args.as_slice()) - .stdin(Ignored) - .stdout(stdout) - .stderr(stderr) - .spawn() + .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 +124,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); } } From 3cd9f4e42822aa8d2de4f4389a24060e6af382ab Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 27 Mar 2015 21:21:37 +0100 Subject: [PATCH 2/3] Move away from as_slice() in contenttest. --- tests/contenttest.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/contenttest.rs b/tests/contenttest.rs index e8b281cf7a2..c8f26ce29af 100644 --- a/tests/contenttest.rs +++ b/tests/contenttest.rs @@ -8,7 +8,6 @@ // except according to those terms. #![feature(collections)] -#![feature(core)] #![feature(exit_status)] #![feature(path)] #![feature(rustc_private)] @@ -48,7 +47,7 @@ fn main() { fn parse_config(args: Vec) -> Config { let args = args.tail(); let opts = vec!(reqopt("s", "source-dir", "source-dir", "source-dir")); - let matches = match getopts(args, opts.as_slice()) { + let matches = match getopts(args, &opts) { Ok(m) => m, Err(f) => panic!(f.to_string()) }; @@ -97,7 +96,7 @@ 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 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() { @@ -105,7 +104,7 @@ fn run_test(file: String) { _ => panic!("could not pop directory"), }; let output = match Command::new(prc_arg.to_str().unwrap()) - .args(args.as_slice()) + .args(&args) .stdin(Stdio::null()) .stderr(Stdio::inherit()) .output() From 0ffa02eec82d25e7fbd24dbe5ce5ed56bb899c82 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 27 Mar 2015 21:22:28 +0100 Subject: [PATCH 3/3] Fix indentation in contenttest. --- tests/contenttest.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/contenttest.rs b/tests/contenttest.rs index c8f26ce29af..67e24187b96 100644 --- a/tests/contenttest.rs +++ b/tests/contenttest.rs @@ -48,8 +48,8 @@ fn parse_config(args: Vec) -> Config { let args = args.tail(); let opts = vec!(reqopt("s", "source-dir", "source-dir", "source-dir")); let matches = match getopts(args, &opts) { - Ok(m) => m, - Err(f) => panic!(f.to_string()) + Ok(m) => m, + Err(f) => panic!(f.to_string()) }; Config {