mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-08 13:02:50 +00:00
Add --nocapture option to rustdoc
This commit is contained in:
parent
68511b574f
commit
6ca0e5ed39
@ -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,
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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")
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user