Add --nocapture option to rustdoc
This commit is contained in:
parent
68511b574f
commit
6ca0e5ed39
4 changed files with 18 additions and 0 deletions
|
@ -156,6 +156,8 @@ crate struct Options {
|
||||||
crate run_check: bool,
|
crate run_check: bool,
|
||||||
/// Whether doctests should emit unused externs
|
/// Whether doctests should emit unused externs
|
||||||
crate json_unused_externs: bool,
|
crate json_unused_externs: bool,
|
||||||
|
/// Whether to skip capturing stdout and stderr of tests.
|
||||||
|
crate nocapture: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for Options {
|
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("enable-per-target-ignores", &self.enable_per_target_ignores)
|
||||||
.field("run_check", &self.run_check)
|
.field("run_check", &self.run_check)
|
||||||
.field("no_run", &self.no_run)
|
.field("no_run", &self.no_run)
|
||||||
|
.field("nocapture", &self.nocapture)
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -627,6 +630,7 @@ impl Options {
|
||||||
let run_check = matches.opt_present("check");
|
let run_check = matches.opt_present("check");
|
||||||
let generate_redirect_map = matches.opt_present("generate-redirect-map");
|
let generate_redirect_map = matches.opt_present("generate-redirect-map");
|
||||||
let show_type_layout = matches.opt_present("show-type-layout");
|
let show_type_layout = matches.opt_present("show-type-layout");
|
||||||
|
let nocapture = matches.opt_present("nocapture");
|
||||||
|
|
||||||
let (lint_opts, describe_lints, lint_cap, _) =
|
let (lint_opts, describe_lints, lint_cap, _) =
|
||||||
get_cmd_lint_options(matches, error_format, &debugging_opts);
|
get_cmd_lint_options(matches, error_format, &debugging_opts);
|
||||||
|
@ -665,6 +669,7 @@ impl Options {
|
||||||
test_builder,
|
test_builder,
|
||||||
run_check,
|
run_check,
|
||||||
no_run,
|
no_run,
|
||||||
|
nocapture,
|
||||||
render_options: RenderOptions {
|
render_options: RenderOptions {
|
||||||
output,
|
output,
|
||||||
external_html,
|
external_html,
|
||||||
|
|
|
@ -107,6 +107,7 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
|
||||||
|
|
||||||
let mut test_args = options.test_args.clone();
|
let mut test_args = options.test_args.clone();
|
||||||
let display_warnings = options.display_warnings;
|
let display_warnings = options.display_warnings;
|
||||||
|
let nocapture = options.nocapture;
|
||||||
let externs = options.externs.clone();
|
let externs = options.externs.clone();
|
||||||
let json_unused_externs = options.json_unused_externs;
|
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());
|
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)));
|
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);
|
return Err(TestFailure::UnexpectedRunPass);
|
||||||
} else if !should_panic && !out.status.success() {
|
} else if !should_panic && !out.status.success() {
|
||||||
return Err(TestFailure::ExecutionFailure(out));
|
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| {
|
unstable("show-type-layout", |o| {
|
||||||
o.optflagmulti("", "show-type-layout", "Include the memory layout of types in the docs")
|
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);
|
find_testable_code(&input_str, &mut collector, codes, options.enable_per_target_ignores, None);
|
||||||
|
|
||||||
options.test_args.insert(0, "rustdoctest".to_string());
|
options.test_args.insert(0, "rustdoctest".to_string());
|
||||||
|
if options.nocapture {
|
||||||
|
options.test_args.push("--nocapture".to_string());
|
||||||
|
}
|
||||||
test::test_main(
|
test::test_main(
|
||||||
&options.test_args,
|
&options.test_args,
|
||||||
collector.tests,
|
collector.tests,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue