about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustdoc/config.rs5
-rw-r--r--src/librustdoc/doctest.rs7
-rw-r--r--src/librustdoc/lib.rs3
-rw-r--r--src/librustdoc/markdown.rs3
4 files changed, 18 insertions, 0 deletions
diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs
index 4cf647a81ae..adbdde0d92c 100644
--- a/src/librustdoc/config.rs
+++ b/src/librustdoc/config.rs
@@ -156,6 +156,8 @@ crate struct Options {
     crate run_check: bool,
     /// Whether doctests should emit unused externs
     crate json_unused_externs: bool,
+    /// Whether to skip capturing stdout and stderr of tests.
+    crate nocapture: bool,
 }
 
 impl fmt::Debug for Options {
@@ -199,6 +201,7 @@ impl fmt::Debug for Options {
             .field("enable-per-target-ignores", &self.enable_per_target_ignores)
             .field("run_check", &self.run_check)
             .field("no_run", &self.no_run)
+            .field("nocapture", &self.nocapture)
             .finish()
     }
 }
@@ -627,6 +630,7 @@ impl Options {
         let run_check = matches.opt_present("check");
         let generate_redirect_map = matches.opt_present("generate-redirect-map");
         let show_type_layout = matches.opt_present("show-type-layout");
+        let nocapture = matches.opt_present("nocapture");
 
         let (lint_opts, describe_lints, lint_cap, _) =
             get_cmd_lint_options(matches, error_format, &debugging_opts);
@@ -665,6 +669,7 @@ impl Options {
             test_builder,
             run_check,
             no_run,
+            nocapture,
             render_options: RenderOptions {
                 output,
                 external_html,
diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs
index c5ca396e720..a9126049b58 100644
--- a/src/librustdoc/doctest.rs
+++ b/src/librustdoc/doctest.rs
@@ -107,6 +107,7 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
 
     let mut test_args = options.test_args.clone();
     let display_warnings = options.display_warnings;
+    let nocapture = options.nocapture;
     let externs = options.externs.clone();
     let json_unused_externs = options.json_unused_externs;
 
@@ -166,6 +167,9 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
     };
 
     test_args.insert(0, "rustdoctest".to_string());
+    if nocapture {
+        test_args.push("--nocapture".to_string());
+    }
 
     test::test_main(&test_args, tests, Some(test::Options::new().display_output(display_warnings)));
 
@@ -463,6 +467,9 @@ fn run_test(
                 return Err(TestFailure::UnexpectedRunPass);
             } else if !should_panic && !out.status.success() {
                 return Err(TestFailure::ExecutionFailure(out));
+            } else if options.nocapture {
+                io::stdout().write_all(&out.stdout).expect("failed to write stdout");
+                io::stderr().write_all(&out.stderr).expect("failed to write stderr");
             }
         }
     }
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index d4d87819c0d..19deaa11388 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -604,6 +604,9 @@ fn opts() -> Vec<RustcOptGroup> {
         unstable("show-type-layout", |o| {
             o.optflagmulti("", "show-type-layout", "Include the memory layout of types in the docs")
         }),
+        unstable("nocapture", |o| {
+            o.optflag("", "nocapture", "Don't capture stdout and stderr of tests")
+        }),
     ]
 }
 
diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs
index 45966c0058d..6c8b95c04c9 100644
--- a/src/librustdoc/markdown.rs
+++ b/src/librustdoc/markdown.rs
@@ -136,6 +136,9 @@ crate fn test(mut options: Options) -> Result<(), String> {
     find_testable_code(&input_str, &mut collector, codes, options.enable_per_target_ignores, None);
 
     options.test_args.insert(0, "rustdoctest".to_string());
+    if options.nocapture {
+        options.test_args.push("--nocapture".to_string());
+    }
     test::test_main(
         &options.test_args,
         collector.tests,