Skip to content

Commit 7e9de3f

Browse files
committed
Auto merge of #12478 - weihanglo:keep-going, r=epage
feat: remove `--keep-going` from `cargo test/bench`
2 parents 42f1798 + de8b913 commit 7e9de3f

File tree

13 files changed

+83
-37
lines changed

13 files changed

+83
-37
lines changed

src/bin/cargo/commands/bench.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ pub fn cli() -> Command {
4242
"Benchmark all targets",
4343
)
4444
.arg_features()
45-
.arg_jobs()
45+
.arg_jobs_without_keep_going()
46+
.arg(flag("keep-going", "Use `--no-fail-fast` instead").hide(true)) // See rust-lang/cargo#11702
4647
.arg_profile("Build artifacts with the specified profile")
4748
.arg_target_triple("Build for the target triple")
4849
.arg_target_dir()
@@ -54,6 +55,17 @@ pub fn cli() -> Command {
5455

5556
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
5657
let ws = args.workspace(config)?;
58+
59+
if args.keep_going() {
60+
return Err(anyhow::format_err!(
61+
"\
62+
unexpected argument `--keep-going` found
63+
64+
tip: to run as many benchmarks as possible without failing fast, use `--no-fail-fast`"
65+
)
66+
.into());
67+
}
68+
5769
let mut compile_opts = args.compile_options(
5870
config,
5971
CompileMode::Bench,

src/bin/cargo/commands/test.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ pub fn cli() -> Command {
4848
"Test all targets (does not include doctests)",
4949
)
5050
.arg_features()
51-
.arg_jobs()
51+
.arg_jobs_without_keep_going()
52+
.arg(flag("keep-going", "Use `--no-fail-fast` instead").hide(true)) // See rust-lang/cargo#11702
5253
.arg_release("Build artifacts in release mode, with optimizations")
5354
.arg_profile("Build artifacts with the specified profile")
5455
.arg_target_triple("Build for the target triple")
@@ -65,6 +66,16 @@ pub fn cli() -> Command {
6566
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
6667
let ws = args.workspace(config)?;
6768

69+
if args.keep_going() {
70+
return Err(anyhow::format_err!(
71+
"\
72+
unexpected argument `--keep-going` found
73+
74+
tip: to run as many tests as possible without failing fast, use `--no-fail-fast`"
75+
)
76+
.into());
77+
}
78+
6879
let mut compile_opts = args.compile_options(
6980
config,
7081
CompileMode::Test,

src/cargo/util/command_prelude.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,23 @@ pub trait CommandExt: Sized {
8383
}
8484

8585
fn arg_jobs(self) -> Self {
86+
self.arg_jobs_without_keep_going()._arg(
87+
flag(
88+
"keep-going",
89+
"Do not abort the build as soon as there is an error (unstable)",
90+
)
91+
.help_heading(heading::COMPILATION_OPTIONS),
92+
)
93+
}
94+
95+
fn arg_jobs_without_keep_going(self) -> Self {
8696
self._arg(
8797
opt("jobs", "Number of parallel jobs, defaults to # of CPUs.")
8898
.short('j')
8999
.value_name("N")
90100
.allow_hyphen_values(true)
91101
.help_heading(heading::COMPILATION_OPTIONS),
92102
)
93-
._arg(
94-
flag(
95-
"keep-going",
96-
"Do not abort the build as soon as there is an error (unstable)",
97-
)
98-
.help_heading(heading::COMPILATION_OPTIONS),
99-
)
100103
}
101104

102105
fn arg_targets_all(

src/doc/man/cargo-test.md

-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ includes an option to control the number of threads used:
186186
{{#options}}
187187

188188
{{> options-jobs }}
189-
{{> options-keep-going }}
190189
{{> options-future-incompat }}
191190

192191
{{/options}}

src/doc/man/generated_txt/cargo-test.txt

-5
Original file line numberDiff line numberDiff line change
@@ -442,11 +442,6 @@ OPTIONS
442442
If a string default is provided, it sets the value back to defaults.
443443
Should not be 0.
444444

445-
--keep-going
446-
Build as many crates in the dependency graph as possible, rather
447-
than aborting the build on the first one that fails to build.
448-
Unstable, requires -Zunstable-options.
449-
450445
--future-incompat-report
451446
Displays a future-incompat report for any future-incompatible
452447
warnings produced during execution of this command

src/doc/src/commands/cargo-test.md

-6
Original file line numberDiff line numberDiff line change
@@ -515,12 +515,6 @@ a string <code>default</code> is provided, it sets the value back to defaults.
515515
Should not be 0.</dd>
516516

517517

518-
<dt class="option-term" id="option-cargo-test---keep-going"><a class="option-anchor" href="#option-cargo-test---keep-going"></a><code>--keep-going</code></dt>
519-
<dd class="option-desc">Build as many crates in the dependency graph as possible, rather than aborting
520-
the build on the first one that fails to build. Unstable, requires
521-
<code>-Zunstable-options</code>.</dd>
522-
523-
524518
<dt class="option-term" id="option-cargo-test---future-incompat-report"><a class="option-anchor" href="#option-cargo-test---future-incompat-report"></a><code>--future-incompat-report</code></dt>
525519
<dd class="option-desc">Displays a future-incompat report for any future-incompatible warnings
526520
produced during execution of this command</p>

src/etc/_cargo

+8-4
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ _cargo() {
4545
'(--bench --bin --example --lib)--test=[specify test name]:test name'
4646
)
4747

48-
parallel=(
48+
jobs=(
4949
'(-j --jobs)'{-j+,--jobs=}'[specify number of parallel jobs]:jobs [# of CPUs]'
50-
'--keep-going[do not abort build on first error]'
50+
)
51+
52+
parallel=(
53+
"${jobs[@]}"
54+
'--keep-going[do not abort build on first build error]'
5155
)
5256

5357
features=(
@@ -87,7 +91,7 @@ _cargo() {
8791
'*:args:_default'
8892
;;
8993
bench)
90-
_arguments -s -A "^--" $common $parallel $features $msgfmt $triple $target $manifest \
94+
_arguments -s -A "^--" $common $jobs $features $msgfmt $triple $target $manifest \
9195
"${command_scope_spec[@]}" \
9296
'--all-targets[benchmark all targets]' \
9397
"--no-run[compile but don't run]" \
@@ -297,7 +301,7 @@ _cargo() {
297301
;;
298302

299303
test | t)
300-
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
304+
_arguments -s -S $common $jobs $features $msgfmt $triple $target $manifest \
301305
'--test=[test name]: :_cargo_test_names' \
302306
'--no-fail-fast[run all tests regardless of failure]' \
303307
'--no-run[compile but do not run]' \

src/etc/cargo.bashcomp.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,16 @@ _cargo()
4141
local opt_pkg='-p --package'
4242
local opt_feat='-F --features --all-features --no-default-features'
4343
local opt_mani='--manifest-path'
44-
local opt_parallel='-j --jobs --keep-going'
44+
local opt_jobs='-j --jobs'
45+
local opt_parallel="$opt_jobs --keep-going"
4546
local opt_force='-f --force'
4647
local opt_sync='-s --sync'
4748
local opt_lock='--frozen --locked --offline'
4849
local opt_targets="--lib --bin --bins --example --examples --test --tests --bench --benches --all-targets"
4950

5051
local opt___nocmd="$opt_common -V --version --list --explain"
5152
local opt__add="$opt_common -p --package --features --default-features --no-default-features $opt_mani --optional --no-optional --rename --dry-run --path --git --branch --tag --rev --registry --dev --build --target"
52-
local opt__bench="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_parallel $opt_targets --message-format --target --no-run --no-fail-fast --target-dir --ignore-rust-version"
53+
local opt__bench="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_jobs $opt_targets --message-format --target --no-run --no-fail-fast --target-dir --ignore-rust-version"
5354
local opt__build="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_parallel $opt_targets --message-format --target --release --profile --target-dir --ignore-rust-version"
5455
local opt__b="$opt__build"
5556
local opt__check="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_parallel $opt_targets --message-format --target --release --profile --target-dir --ignore-rust-version"
@@ -82,7 +83,7 @@ _cargo()
8283
local opt__rustc="$opt_common $opt_pkg $opt_feat $opt_mani $opt_lock $opt_parallel $opt_targets -L --crate-type --extern --message-format --profile --target --release --target-dir --ignore-rust-version"
8384
local opt__rustdoc="$opt_common $opt_pkg $opt_feat $opt_mani $opt_lock $opt_parallel $opt_targets --message-format --target --release --open --target-dir --profile --ignore-rust-version"
8485
local opt__search="$opt_common $opt_lock --limit --index --registry"
85-
local opt__test="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_parallel $opt_targets --message-format --doc --target --no-run --release --no-fail-fast --target-dir --profile --ignore-rust-version"
86+
local opt__test="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_jobs $opt_targets --message-format --doc --target --no-run --release --no-fail-fast --target-dir --profile --ignore-rust-version"
8687
local opt__t="$opt__test"
8788
local opt__tree="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock --target -i --invert --prefix --no-dedupe --duplicates -d --charset -f --format -e --edges"
8889
local opt__uninstall="$opt_common $opt_lock $opt_pkg --bin --root"

src/etc/man/cargo-test.1

-7
Original file line numberDiff line numberDiff line change
@@ -535,13 +535,6 @@ a string \fBdefault\fR is provided, it sets the value back to defaults.
535535
Should not be 0.
536536
.RE
537537
.sp
538-
\fB\-\-keep\-going\fR
539-
.RS 4
540-
Build as many crates in the dependency graph as possible, rather than aborting
541-
the build on the first one that fails to build. Unstable, requires
542-
\fB\-Zunstable\-options\fR\&.
543-
.RE
544-
.sp
545538
\fB\-\-future\-incompat\-report\fR
546539
.RS 4
547540
Displays a future\-incompat report for any future\-incompatible warnings

tests/testsuite/bench.rs

+18
Original file line numberDiff line numberDiff line change
@@ -1670,3 +1670,21 @@ fn json_artifact_includes_executable_for_benchmark() {
16701670
)
16711671
.run();
16721672
}
1673+
1674+
#[cargo_test]
1675+
fn cargo_bench_no_keep_going() {
1676+
let p = project()
1677+
.file("Cargo.toml", &basic_bin_manifest("foo"))
1678+
.file("src/main.rs", "")
1679+
.build();
1680+
1681+
p.cargo("bench --keep-going")
1682+
.with_stderr(
1683+
"\
1684+
error: unexpected argument `--keep-going` found
1685+
1686+
tip: to run as many benchmarks as possible without failing fast, use `--no-fail-fast`",
1687+
)
1688+
.with_status(101)
1689+
.run();
1690+
}

tests/testsuite/cargo_bench/help/stdout.log

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ Feature Selection:
4444

4545
Compilation Options:
4646
-j, --jobs <N> Number of parallel jobs, defaults to # of CPUs.
47-
--keep-going Do not abort the build as soon as there is an error (unstable)
4847
--profile <PROFILE-NAME> Build artifacts with the specified profile
4948
--target <TRIPLE> Build for the target triple
5049
--target-dir <DIRECTORY> Directory for all generated artifacts

tests/testsuite/cargo_test/help/stdout.log

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ Feature Selection:
4646

4747
Compilation Options:
4848
-j, --jobs <N> Number of parallel jobs, defaults to # of CPUs.
49-
--keep-going Do not abort the build as soon as there is an error (unstable)
5049
-r, --release Build artifacts in release mode, with optimizations
5150
--profile <PROFILE-NAME> Build artifacts with the specified profile
5251
--target <TRIPLE> Build for the target triple

tests/testsuite/test.rs

+18
Original file line numberDiff line numberDiff line change
@@ -4843,3 +4843,21 @@ error: 2 targets failed:
48434843
.with_status(101)
48444844
.run();
48454845
}
4846+
4847+
#[cargo_test]
4848+
fn cargo_test_no_keep_going() {
4849+
let p = project()
4850+
.file("Cargo.toml", &basic_bin_manifest("foo"))
4851+
.file("src/main.rs", "")
4852+
.build();
4853+
4854+
p.cargo("test --keep-going")
4855+
.with_stderr(
4856+
"\
4857+
error: unexpected argument `--keep-going` found
4858+
4859+
tip: to run as many tests as possible without failing fast, use `--no-fail-fast`",
4860+
)
4861+
.with_status(101)
4862+
.run();
4863+
}

0 commit comments

Comments
 (0)