Skip to content

Commit 5b249f8

Browse files
authored
Rollup merge of #134809 - clubby789:nocapture, r=jieyouxu
Add `--no-capture`/`--nocapture` as bootstrap arguments I often try `x test ... --nocapture` => 'unknown argument' => `x test ... -- --nocapture`. As we forward several other compiletest flags, let's recognise this one in bootstrap as well.
2 parents 7ba9655 + 35bbb01 commit 5b249f8

File tree

13 files changed

+36
-3
lines changed

13 files changed

+36
-3
lines changed

Diff for: src/bootstrap/src/core/build_steps/test.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1829,6 +1829,10 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
18291829
cmd.arg("--force-rerun");
18301830
}
18311831

1832+
if builder.config.cmd.no_capture() {
1833+
cmd.arg("--no-capture");
1834+
}
1835+
18321836
let compare_mode =
18331837
builder.config.cmd.compare_mode().or_else(|| {
18341838
if builder.config.test_compare_mode { self.compare_mode } else { None }

Diff for: src/bootstrap/src/core/builder/tests.rs

+2
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,7 @@ mod dist {
637637
run: None,
638638
only_modified: false,
639639
extra_checks: None,
640+
no_capture: false,
640641
};
641642

642643
let build = Build::new(config);
@@ -702,6 +703,7 @@ mod dist {
702703
run: None,
703704
only_modified: false,
704705
extra_checks: None,
706+
no_capture: false,
705707
};
706708
// Make sure rustfmt binary not being found isn't an error.
707709
config.channel = "beta".to_string();

Diff for: src/bootstrap/src/core/config/flags.rs

+10
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,9 @@ pub enum Subcommand {
388388
/// enable this to generate a Rustfix coverage file, which is saved in
389389
/// `/<build_base>/rustfix_missing_coverage.txt`
390390
rustfix_coverage: bool,
391+
#[arg(long)]
392+
/// don't capture stdout/stderr of tests
393+
no_capture: bool,
391394
},
392395
/// Build and run some test suites *in Miri*
393396
Miri {
@@ -563,6 +566,13 @@ impl Subcommand {
563566
}
564567
}
565568

569+
pub fn no_capture(&self) -> bool {
570+
match *self {
571+
Subcommand::Test { no_capture, .. } => no_capture,
572+
_ => false,
573+
}
574+
}
575+
566576
pub fn rustfix_coverage(&self) -> bool {
567577
match *self {
568578
Subcommand::Test { rustfix_coverage, .. } => rustfix_coverage,

Diff for: src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -315,4 +315,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
315315
severity: ChangeSeverity::Info,
316316
summary: "`build.vendor` is now enabled by default for dist/tarball sources when 'vendor' directory and '.cargo/config.toml' file are present.",
317317
},
318+
ChangeInfo {
319+
change_id: 134809,
320+
severity: ChangeSeverity::Warning,
321+
summary: "compiletest now takes `--no-capture` instead of `--nocapture`; bootstrap now accepts `--no-capture` as an argument to test commands directly",
322+
},
318323
];

Diff for: src/etc/completions/x.fish

+1
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ complete -c x -n "__fish_x_using_subcommand test" -l bless -d 'whether to automa
319319
complete -c x -n "__fish_x_using_subcommand test" -l force-rerun -d 'rerun tests even if the inputs are unchanged'
320320
complete -c x -n "__fish_x_using_subcommand test" -l only-modified -d 'only run tests that result has been changed'
321321
complete -c x -n "__fish_x_using_subcommand test" -l rustfix-coverage -d 'enable this to generate a Rustfix coverage file, which is saved in `/<build_base>/rustfix_missing_coverage.txt`'
322+
complete -c x -n "__fish_x_using_subcommand test" -l no-capture -d 'don\'t capture stdout/stderr of tests'
322323
complete -c x -n "__fish_x_using_subcommand test" -s v -l verbose -d 'use verbose output (-vv for very verbose)'
323324
complete -c x -n "__fish_x_using_subcommand test" -s i -l incremental -d 'use incremental compilation'
324325
complete -c x -n "__fish_x_using_subcommand test" -l include-default-paths -d 'include default paths in addition to the provided ones'

Diff for: src/etc/completions/x.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ Register-ArgumentCompleter -Native -CommandName 'x' -ScriptBlock {
366366
[CompletionResult]::new('--force-rerun', '--force-rerun', [CompletionResultType]::ParameterName, 'rerun tests even if the inputs are unchanged')
367367
[CompletionResult]::new('--only-modified', '--only-modified', [CompletionResultType]::ParameterName, 'only run tests that result has been changed')
368368
[CompletionResult]::new('--rustfix-coverage', '--rustfix-coverage', [CompletionResultType]::ParameterName, 'enable this to generate a Rustfix coverage file, which is saved in `/<build_base>/rustfix_missing_coverage.txt`')
369+
[CompletionResult]::new('--no-capture', '--no-capture', [CompletionResultType]::ParameterName, 'don''t capture stdout/stderr of tests')
369370
[CompletionResult]::new('-v', '-v', [CompletionResultType]::ParameterName, 'use verbose output (-vv for very verbose)')
370371
[CompletionResult]::new('--verbose', '--verbose', [CompletionResultType]::ParameterName, 'use verbose output (-vv for very verbose)')
371372
[CompletionResult]::new('-i', '-i', [CompletionResultType]::ParameterName, 'use incremental compilation')

Diff for: src/etc/completions/x.py.fish

+1
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ complete -c x.py -n "__fish_x.py_using_subcommand test" -l bless -d 'whether to
319319
complete -c x.py -n "__fish_x.py_using_subcommand test" -l force-rerun -d 'rerun tests even if the inputs are unchanged'
320320
complete -c x.py -n "__fish_x.py_using_subcommand test" -l only-modified -d 'only run tests that result has been changed'
321321
complete -c x.py -n "__fish_x.py_using_subcommand test" -l rustfix-coverage -d 'enable this to generate a Rustfix coverage file, which is saved in `/<build_base>/rustfix_missing_coverage.txt`'
322+
complete -c x.py -n "__fish_x.py_using_subcommand test" -l no-capture -d 'don\'t capture stdout/stderr of tests'
322323
complete -c x.py -n "__fish_x.py_using_subcommand test" -s v -l verbose -d 'use verbose output (-vv for very verbose)'
323324
complete -c x.py -n "__fish_x.py_using_subcommand test" -s i -l incremental -d 'use incremental compilation'
324325
complete -c x.py -n "__fish_x.py_using_subcommand test" -l include-default-paths -d 'include default paths in addition to the provided ones'

Diff for: src/etc/completions/x.py.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock {
366366
[CompletionResult]::new('--force-rerun', '--force-rerun', [CompletionResultType]::ParameterName, 'rerun tests even if the inputs are unchanged')
367367
[CompletionResult]::new('--only-modified', '--only-modified', [CompletionResultType]::ParameterName, 'only run tests that result has been changed')
368368
[CompletionResult]::new('--rustfix-coverage', '--rustfix-coverage', [CompletionResultType]::ParameterName, 'enable this to generate a Rustfix coverage file, which is saved in `/<build_base>/rustfix_missing_coverage.txt`')
369+
[CompletionResult]::new('--no-capture', '--no-capture', [CompletionResultType]::ParameterName, 'don''t capture stdout/stderr of tests')
369370
[CompletionResult]::new('-v', '-v', [CompletionResultType]::ParameterName, 'use verbose output (-vv for very verbose)')
370371
[CompletionResult]::new('--verbose', '--verbose', [CompletionResultType]::ParameterName, 'use verbose output (-vv for very verbose)')
371372
[CompletionResult]::new('-i', '-i', [CompletionResultType]::ParameterName, 'use incremental compilation')

Diff for: src/etc/completions/x.py.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3119,7 +3119,7 @@ _x.py() {
31193119
return 0
31203120
;;
31213121
x.py__test)
3122-
opts="-v -i -j -h --no-fail-fast --test-args --compiletest-rustc-args --no-doc --doc --bless --extra-checks --force-rerun --only-modified --compare-mode --pass --run --rustfix-coverage --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --dump-bootstrap-shims --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --bypass-bootstrap-lock --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [PATHS]... [ARGS]..."
3122+
opts="-v -i -j -h --no-fail-fast --test-args --compiletest-rustc-args --no-doc --doc --bless --extra-checks --force-rerun --only-modified --compare-mode --pass --run --rustfix-coverage --no-capture --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --dump-bootstrap-shims --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --bypass-bootstrap-lock --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [PATHS]... [ARGS]..."
31233123
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
31243124
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
31253125
return 0

Diff for: src/etc/completions/x.py.zsh

+1
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ _arguments "${_arguments_options[@]}" : \
365365
'--force-rerun[rerun tests even if the inputs are unchanged]' \
366366
'--only-modified[only run tests that result has been changed]' \
367367
'--rustfix-coverage[enable this to generate a Rustfix coverage file, which is saved in \`/<build_base>/rustfix_missing_coverage.txt\`]' \
368+
'--no-capture[don'\''t capture stdout/stderr of tests]' \
368369
'*-v[use verbose output (-vv for very verbose)]' \
369370
'*--verbose[use verbose output (-vv for very verbose)]' \
370371
'-i[use incremental compilation]' \

Diff for: src/etc/completions/x.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3119,7 +3119,7 @@ _x() {
31193119
return 0
31203120
;;
31213121
x__test)
3122-
opts="-v -i -j -h --no-fail-fast --test-args --compiletest-rustc-args --no-doc --doc --bless --extra-checks --force-rerun --only-modified --compare-mode --pass --run --rustfix-coverage --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --dump-bootstrap-shims --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --bypass-bootstrap-lock --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [PATHS]... [ARGS]..."
3122+
opts="-v -i -j -h --no-fail-fast --test-args --compiletest-rustc-args --no-doc --doc --bless --extra-checks --force-rerun --only-modified --compare-mode --pass --run --rustfix-coverage --no-capture --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --dump-bootstrap-shims --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --bypass-bootstrap-lock --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [PATHS]... [ARGS]..."
31233123
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
31243124
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
31253125
return 0

Diff for: src/etc/completions/x.zsh

+1
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ _arguments "${_arguments_options[@]}" : \
365365
'--force-rerun[rerun tests even if the inputs are unchanged]' \
366366
'--only-modified[only run tests that result has been changed]' \
367367
'--rustfix-coverage[enable this to generate a Rustfix coverage file, which is saved in \`/<build_base>/rustfix_missing_coverage.txt\`]' \
368+
'--no-capture[don'\''t capture stdout/stderr of tests]' \
368369
'*-v[use verbose output (-vv for very verbose)]' \
369370
'*--verbose[use verbose output (-vv for very verbose)]' \
370371
'-i[use incremental compilation]' \

Diff for: src/tools/compiletest/src/lib.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ pub fn parse_config(args: Vec<String>) -> Config {
159159
)
160160
.optflag("", "force-rerun", "rerun tests even if the inputs are unchanged")
161161
.optflag("", "only-modified", "only run tests that result been modified")
162+
// FIXME: Temporarily retained so we can point users to `--no-capture`
162163
.optflag("", "nocapture", "")
164+
.optflag("", "no-capture", "don't capture stdout/stderr of tests")
163165
.optflag("", "profiler-runtime", "is the profiler runtime enabled for this target")
164166
.optflag("h", "help", "show this message")
165167
.reqopt("", "channel", "current Rust channel", "CHANNEL")
@@ -288,6 +290,10 @@ pub fn parse_config(args: Vec<String>) -> Config {
288290
);
289291
})
290292
});
293+
if matches.opt_present("nocapture") {
294+
panic!("`--nocapture` is deprecated; please use `--no-capture`");
295+
}
296+
291297
Config {
292298
bless: matches.opt_present("bless"),
293299
compile_lib_path: make_absolute(opt_path(matches, "compile-lib-path")),
@@ -385,7 +391,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
385391
target_cfgs: OnceLock::new(),
386392
builtin_cfg_names: OnceLock::new(),
387393

388-
nocapture: matches.opt_present("nocapture"),
394+
nocapture: matches.opt_present("no-capture"),
389395

390396
git_repository: matches.opt_str("git-repository").unwrap(),
391397
nightly_branch: matches.opt_str("nightly-branch").unwrap(),

0 commit comments

Comments
 (0)