about summary refs log tree commit diff
path: root/src/compiletest
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-02-12 10:25:09 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-02-14 07:46:29 -0800
commitee2a888860ea496b5a972ed35fb742b4ae008233 (patch)
tree249171a9397fb0a961bb7d19dff6f25e8f587ac1 /src/compiletest
parent665555d58f2aa3c1d8aecd7b34392bde6c41b20d (diff)
extra: Capture stdout/stderr of tests by default
When tests fail, their stdout and stderr is printed as part of the summary, but
this helps suppress failure messages from #[should_fail] tests and generally
clean up the output of the test runner.
Diffstat (limited to 'src/compiletest')
-rw-r--r--src/compiletest/header.rs12
-rw-r--r--src/compiletest/runtest.rs7
2 files changed, 18 insertions, 1 deletions
diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs
index 0c965b7c6c3..38c1162f636 100644
--- a/src/compiletest/header.rs
+++ b/src/compiletest/header.rs
@@ -30,6 +30,8 @@ pub struct TestProps {
     check_lines: ~[~str],
     // Flag to force a crate to be built with the host architecture
     force_host: bool,
+    // Check stdout for error-pattern output as well as stderr
+    check_stdout: bool,
 }
 
 // Load any test directives embedded in the file
@@ -42,6 +44,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
     let mut debugger_cmds = ~[];
     let mut check_lines = ~[];
     let mut force_host = false;
+    let mut check_stdout = false;
     iter_header(testfile, |ln| {
         match parse_error_pattern(ln) {
           Some(ep) => error_patterns.push(ep),
@@ -60,6 +63,10 @@ pub fn load_props(testfile: &Path) -> TestProps {
             force_host = parse_force_host(ln);
         }
 
+        if !check_stdout {
+            check_stdout = parse_check_stdout(ln);
+        }
+
         match parse_aux_build(ln) {
             Some(ab) => { aux_builds.push(ab); }
             None => {}
@@ -91,6 +98,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
         debugger_cmds: debugger_cmds,
         check_lines: check_lines,
         force_host: force_host,
+        check_stdout: check_stdout,
     };
 }
 
@@ -155,6 +163,10 @@ fn parse_force_host(line: &str) -> bool {
     parse_name_directive(line, "force-host")
 }
 
+fn parse_check_stdout(line: &str) -> bool {
+    parse_name_directive(line, "check-stdout")
+}
+
 fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
     parse_name_value_directive(line, ~"exec-env").map(|nv| {
         // nv is either FOO or FOO=BAR
diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs
index a2c61352e6f..8b45d987864 100644
--- a/src/compiletest/runtest.rs
+++ b/src/compiletest/runtest.rs
@@ -452,7 +452,12 @@ fn check_error_patterns(props: &TestProps,
     let mut next_err_idx = 0u;
     let mut next_err_pat = &props.error_patterns[next_err_idx];
     let mut done = false;
-    for line in ProcRes.stderr.lines() {
+    let output_to_check = if props.check_stdout {
+        ProcRes.stdout + ProcRes.stderr
+    } else {
+        ProcRes.stderr.clone()
+    };
+    for line in output_to_check.lines() {
         if line.contains(*next_err_pat) {
             debug!("found error pattern {}", *next_err_pat);
             next_err_idx += 1u;