Skip to content

Commit 961f76f

Browse files
authored
Rollup merge of rust-lang#148115 - fmease:rustdoc-no-capture, r=notriddle
rustdoc: Rename unstable option `--nocapture` to `--no-capture` in accordance with `libtest` Context: rust-lang#133073, rust-lang#139224 (TL;DR: `libtest` has soft-deprecated `--nocapture` in favor a new & stable `--no-capture`; we should follow suit). Since the rustdoc flag is unstable (tracking issue: rust-lang#148116), we're allowed to remove the old flag immediately. However since the flag has existed for 4 years we could hard-deprecate the flag first or at least be considerate and provide a diagnostic referring users to the new flag. This PR does neither. Let me know what you would think would be best. Cargo doesn't use this flag, not yet at least (rust-lang/cargo#9705), so we really are free to sunset this flag without bigger consequences.
2 parents 6f201c5 + 11b82e1 commit 961f76f

File tree

13 files changed

+22
-22
lines changed

13 files changed

+22
-22
lines changed

src/doc/rustdoc/src/unstable-features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ Using `index-page` option enables `enable-index-page` option as well.
362362

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

365-
## `--nocapture`: disable output capture for test
365+
## `--no-capture`: disable output capture for test
366366

367367
When this flag is used with `--test`, the output (stdout and stderr) of your tests won't be
368368
captured by rustdoc. Instead, the output will be directed to your terminal,

src/librustdoc/config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub(crate) struct Options {
155155
/// Whether doctests should emit unused externs
156156
pub(crate) json_unused_externs: JsonUnusedExterns,
157157
/// Whether to skip capturing stdout and stderr of tests.
158-
pub(crate) nocapture: bool,
158+
pub(crate) no_capture: bool,
159159

160160
/// Configuration for scraping examples from the current crate. If this option is Some(..) then
161161
/// the compiler will scrape examples and not generate documentation.
@@ -211,7 +211,7 @@ impl fmt::Debug for Options {
211211
.field("no_run", &self.no_run)
212212
.field("test_builder_wrappers", &self.test_builder_wrappers)
213213
.field("remap-file-prefix", &self.remap_path_prefix)
214-
.field("nocapture", &self.nocapture)
214+
.field("no_capture", &self.no_capture)
215215
.field("scrape_examples_options", &self.scrape_examples_options)
216216
.field("unstable_features", &self.unstable_features)
217217
.finish()
@@ -783,7 +783,7 @@ impl Options {
783783
let run_check = matches.opt_present("check");
784784
let generate_redirect_map = matches.opt_present("generate-redirect-map");
785785
let show_type_layout = matches.opt_present("show-type-layout");
786-
let nocapture = matches.opt_present("nocapture");
786+
let no_capture = matches.opt_present("no-capture");
787787
let generate_link_to_definition = matches.opt_present("generate-link-to-definition");
788788
let generate_macro_expansion = matches.opt_present("generate-macro-expansion");
789789
let extern_html_root_takes_precedence =
@@ -854,7 +854,7 @@ impl Options {
854854
no_run,
855855
test_builder_wrappers,
856856
remap_path_prefix,
857-
nocapture,
857+
no_capture,
858858
crate_name,
859859
output_format,
860860
json_unused_externs,

src/librustdoc/doctest.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ pub(crate) fn run_tests(
326326
let mut test_args = Vec::with_capacity(rustdoc_options.test_args.len() + 1);
327327
test_args.insert(0, "rustdoctest".to_string());
328328
test_args.extend_from_slice(&rustdoc_options.test_args);
329-
if rustdoc_options.nocapture {
330-
test_args.push("--nocapture".to_string());
329+
if rustdoc_options.no_capture {
330+
test_args.push("--no-capture".to_string());
331331
}
332332

333333
let mut nb_errors = 0;
@@ -644,8 +644,8 @@ fn run_test(
644644
// tested as standalone tests.
645645
return (Duration::default(), Err(TestFailure::CompileError));
646646
}
647-
if !rustdoc_options.nocapture {
648-
// If `nocapture` is disabled, then we don't display rustc's output when compiling
647+
if !rustdoc_options.no_capture {
648+
// If `no_capture` is disabled, then we don't display rustc's output when compiling
649649
// the merged doctests.
650650
compiler.stderr(Stdio::null());
651651
}
@@ -721,8 +721,8 @@ fn run_test(
721721
// tested as standalone tests.
722722
return (instant.elapsed(), Err(TestFailure::CompileError));
723723
}
724-
if !rustdoc_options.nocapture {
725-
// If `nocapture` is disabled, then we don't display rustc's output when compiling
724+
if !rustdoc_options.no_capture {
725+
// If `no_capture` is disabled, then we don't display rustc's output when compiling
726726
// the merged doctests.
727727
runner_compiler.stderr(Stdio::null());
728728
}
@@ -821,7 +821,7 @@ fn run_test(
821821
cmd.current_dir(run_directory);
822822
}
823823

824-
let result = if doctest.is_multiple_tests() || rustdoc_options.nocapture {
824+
let result = if doctest.is_multiple_tests() || rustdoc_options.no_capture {
825825
cmd.status().map(|status| process::Output {
826826
status,
827827
stdout: Vec::new(),
@@ -1016,7 +1016,7 @@ impl CreateRunnableDocTests {
10161016
.span(scraped_test.span)
10171017
.build(dcx);
10181018
let is_standalone = !doctest.can_be_merged
1019-
|| self.rustdoc_options.nocapture
1019+
|| self.rustdoc_options.no_capture
10201020
|| self.rustdoc_options.test_args.iter().any(|arg| arg == "--show-output");
10211021
if is_standalone {
10221022
let test_desc = self.generate_test_desc_and_fn(doctest, scraped_test);

src/librustdoc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ fn opts() -> Vec<RustcOptGroup> {
586586
"Include the memory layout of types in the docs",
587587
"",
588588
),
589-
opt(Unstable, Flag, "", "nocapture", "Don't capture stdout and stderr of tests", ""),
589+
opt(Unstable, Flag, "", "no-capture", "Don't capture stdout and stderr of tests", ""),
590590
opt(
591591
Unstable,
592592
Flag,

tests/run-make/rustdoc-default-output/output-default.stdout

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Options:
158158
Remap source names in compiler messages
159159
--show-type-layout
160160
Include the memory layout of types in the docs
161-
--nocapture Don't capture stdout and stderr of tests
161+
--no-capture Don't capture stdout and stderr of tests
162162
--generate-link-to-definition
163163
Make the identifiers in the HTML source code pages
164164
navigable

tests/rustdoc-ui/doctest/check-cfg-test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ check-pass
2-
//@ compile-flags: --test --nocapture --check-cfg=cfg(feature,values("test")) -Z unstable-options
2+
//@ compile-flags: --test --no-capture --check-cfg=cfg(feature,values("test")) -Z unstable-options
33
//@ normalize-stderr: "tests/rustdoc-ui/doctest" -> "$$DIR"
44
//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR"
55
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"

tests/rustdoc-ui/doctest/nocapture-fail.rs renamed to tests/rustdoc-ui/doctest/no-capture-fail.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ check-pass
2-
//@ compile-flags:--test -Zunstable-options --nocapture
2+
//@ compile-flags:--test -Zunstable-options --no-capture
33
//@ normalize-stderr: "tests/rustdoc-ui/doctest" -> "$$DIR"
44
//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR"
55
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"

tests/rustdoc-ui/doctest/nocapture-fail.stderr renamed to tests/rustdoc-ui/doctest/no-capture-fail.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: struct literal body without path
2-
--> $DIR/nocapture-fail.rs:8:10
2+
--> $DIR/no-capture-fail.rs:8:10
33
|
44
LL | fn foo() {
55
| __________^
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

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

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

tests/rustdoc-ui/doctest/nocapture.rs renamed to tests/rustdoc-ui/doctest/no-capture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ check-pass
2-
//@ compile-flags:--test -Zunstable-options --nocapture
2+
//@ compile-flags:--test -Zunstable-options --no-capture
33
//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR"
44
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
55

0 commit comments

Comments
 (0)