From 3cf4acd44be6312a486e972e0b6decfdb77e8053 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Wed, 7 Oct 2015 15:18:02 -0700 Subject: [PATCH] Record reference test stdout and stderr When reference tests crash it is difficult to debug the issue, because the stacktrace and any other output is discarded by the test harness. Instead of discarding it, write the output to text files in the test results directory which will make it easier to debug crashing tests. --- tests/reftest.rs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/tests/reftest.rs b/tests/reftest.rs index b3df1abb08c..49de8fda1fa 100644 --- a/tests/reftest.rs +++ b/tests/reftest.rs @@ -21,10 +21,10 @@ extern crate util; use std::env; use std::ffi::OsStr; use std::fs::{PathExt, File, walk_dir}; -use std::io::{self, Read, Result}; +use std::io::{self, Read, Result, Write}; use std::path::{Path, PathBuf}; use std::process; -use std::process::{Command, Stdio}; +use std::process::{Command}; use std::thread::sleep_ms; use test::run_tests_console; use test::{AutoColor, DynTestName, DynTestFn, TestDesc, TestOpts, TestDescAndFn, ShouldPanic}; @@ -284,8 +284,6 @@ fn capture(reftest: &Reftest, side: usize) -> (u32, u32, Vec) { let png_filename = format!("/tmp/servo-reftest-{:06}-{}.png", reftest.id, side); let mut command = Command::new(&servo_path()); command - .stdout(Stdio::null()) - .stderr(Stdio::null()) .args(&reftest.servo_args[..]) .arg("--user-stylesheet").arg(util::resource_files::resources_dir_path().join("ahem.css")) // Allows pixel perfect rendering of Ahem font and the HTML canvas for reftests. @@ -317,11 +315,24 @@ fn capture(reftest: &Reftest, side: usize) -> (u32, u32, Vec) { command.arg("--device-pixel-ratio"); command.arg(pixel_ratio.to_string()); } - let retval = match command.status() { - Ok(status) => status, + let (exit_status, stderr, stdout) = match command.output() { + Ok(output) => (output.status, output.stderr, output.stdout), Err(e) => panic!("failed to execute process: {}", e), }; - assert!(retval.success()); + + if !stdout.is_empty() { + let stdout_filename = format!("/tmp/servo-reftest-{:06}-{}-stdout.txt", reftest.id, side); + let mut stdout_file = File::create(stdout_filename).unwrap(); + stdout_file.write_all(&stdout[..]).unwrap(); + } + + if !stderr.is_empty() { + let stderr_filename = format!("/tmp/servo-reftest-{:06}-{}-stderr.txt", reftest.id, side); + let mut stderr_file = File::create(stderr_filename).unwrap(); + stderr_file.write_all(&stderr[..]).unwrap(); + } + + assert!(exit_status.success()); let image = png::load_png(&png_filename).unwrap(); let rgba8_bytes = match image.pixels {