Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/doc/rustdoc/src/unstable-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ Using `index-page` option enables `enable-index-page` option as well.

This feature allows the generation of a default index-page which lists the generated crates.

## `--nocapture`: disable output capture for test
## `--no-capture`: disable output capture for test

When this flag is used with `--test`, the output (stdout and stderr) of your tests won't be
captured by rustdoc. Instead, the output will be directed to your terminal,
Expand Down
8 changes: 4 additions & 4 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub(crate) struct Options {
/// Whether doctests should emit unused externs
pub(crate) json_unused_externs: JsonUnusedExterns,
/// Whether to skip capturing stdout and stderr of tests.
pub(crate) nocapture: bool,
pub(crate) no_capture: bool,

/// Configuration for scraping examples from the current crate. If this option is Some(..) then
/// the compiler will scrape examples and not generate documentation.
Expand Down Expand Up @@ -211,7 +211,7 @@ impl fmt::Debug for Options {
.field("no_run", &self.no_run)
.field("test_builder_wrappers", &self.test_builder_wrappers)
.field("remap-file-prefix", &self.remap_path_prefix)
.field("nocapture", &self.nocapture)
.field("no_capture", &self.no_capture)
.field("scrape_examples_options", &self.scrape_examples_options)
.field("unstable_features", &self.unstable_features)
.finish()
Expand Down Expand Up @@ -785,7 +785,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 no_capture = matches.opt_present("no-capture");
let generate_link_to_definition = matches.opt_present("generate-link-to-definition");
let generate_macro_expansion = matches.opt_present("generate-macro-expansion");
let extern_html_root_takes_precedence =
Expand Down Expand Up @@ -856,7 +856,7 @@ impl Options {
no_run,
test_builder_wrappers,
remap_path_prefix,
nocapture,
no_capture,
crate_name,
output_format,
json_unused_externs,
Expand Down
16 changes: 8 additions & 8 deletions src/librustdoc/doctest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ pub(crate) fn run_tests(
let mut test_args = Vec::with_capacity(rustdoc_options.test_args.len() + 1);
test_args.insert(0, "rustdoctest".to_string());
test_args.extend_from_slice(&rustdoc_options.test_args);
if rustdoc_options.nocapture {
test_args.push("--nocapture".to_string());
if rustdoc_options.no_capture {
test_args.push("--no-capture".to_string());
}

let mut nb_errors = 0;
Expand Down Expand Up @@ -644,8 +644,8 @@ fn run_test(
// tested as standalone tests.
return (Duration::default(), Err(TestFailure::CompileError));
}
if !rustdoc_options.nocapture {
// If `nocapture` is disabled, then we don't display rustc's output when compiling
if !rustdoc_options.no_capture {
// If `no_capture` is disabled, then we don't display rustc's output when compiling
// the merged doctests.
compiler.stderr(Stdio::null());
}
Expand Down Expand Up @@ -721,8 +721,8 @@ fn run_test(
// tested as standalone tests.
return (instant.elapsed(), Err(TestFailure::CompileError));
}
if !rustdoc_options.nocapture {
// If `nocapture` is disabled, then we don't display rustc's output when compiling
if !rustdoc_options.no_capture {
// If `no_capture` is disabled, then we don't display rustc's output when compiling
// the merged doctests.
runner_compiler.stderr(Stdio::null());
}
Expand Down Expand Up @@ -821,7 +821,7 @@ fn run_test(
cmd.current_dir(run_directory);
}

let result = if doctest.is_multiple_tests() || rustdoc_options.nocapture {
let result = if doctest.is_multiple_tests() || rustdoc_options.no_capture {
cmd.status().map(|status| process::Output {
status,
stdout: Vec::new(),
Expand Down Expand Up @@ -1016,7 +1016,7 @@ impl CreateRunnableDocTests {
.span(scraped_test.span)
.build(dcx);
let is_standalone = !doctest.can_be_merged
|| self.rustdoc_options.nocapture
|| self.rustdoc_options.no_capture
|| self.rustdoc_options.test_args.iter().any(|arg| arg == "--show-output");
if is_standalone {
let test_desc = self.generate_test_desc_and_fn(doctest, scraped_test);
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ fn opts() -> Vec<RustcOptGroup> {
"Include the memory layout of types in the docs",
"",
),
opt(Unstable, Flag, "", "nocapture", "Don't capture stdout and stderr of tests", ""),
opt(Unstable, Flag, "", "no-capture", "Don't capture stdout and stderr of tests", ""),
opt(
Unstable,
Flag,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Options:
Remap source names in compiler messages
--show-type-layout
Include the memory layout of types in the docs
--nocapture Don't capture stdout and stderr of tests
--no-capture Don't capture stdout and stderr of tests
--generate-link-to-definition
Make the identifiers in the HTML source code pages
navigable
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc-ui/doctest/check-cfg-test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ check-pass
//@ compile-flags: --test --nocapture --check-cfg=cfg(feature,values("test")) -Z unstable-options
//@ compile-flags: --test --no-capture --check-cfg=cfg(feature,values("test")) -Z unstable-options
//@ normalize-stderr: "tests/rustdoc-ui/doctest" -> "$$DIR"
//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR"
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ check-pass
//@ compile-flags:--test -Zunstable-options --nocapture
//@ compile-flags:--test -Zunstable-options --no-capture
//@ normalize-stderr: "tests/rustdoc-ui/doctest" -> "$$DIR"
//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR"
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: struct literal body without path
--> $DIR/nocapture-fail.rs:8:10
--> $DIR/no-capture-fail.rs:8:10
|
LL | fn foo() {
| __________^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

running 1 test
test $DIR/nocapture-fail.rs - Foo (line 7) - compile fail ... ok
test $DIR/no-capture-fail.rs - Foo (line 7) - compile fail ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ check-pass
//@ compile-flags:--test -Zunstable-options --nocapture
//@ compile-flags:--test -Zunstable-options --no-capture
//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR"
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

running 1 test
hello!
test $DIR/nocapture.rs - Foo (line 6) ... ok
test $DIR/no-capture.rs - Foo (line 6) ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME

2 changes: 1 addition & 1 deletion tests/rustdoc-ui/doctest/non_local_defs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ check-pass
//@ compile-flags:--test --test-args --test-threads=1 --nocapture -Zunstable-options
//@ compile-flags:--test --test-args --test-threads=1 --no-capture -Zunstable-options
//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR"
//@ normalize-stderr: "tests/rustdoc-ui/doctest" -> "$$DIR"
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
Expand Down
Loading