Skip to content

Commit 5ae529b

Browse files
committed
feat: remove --keep-going from cargo test/bench
It confuses people that both `--no-fail-fast` and `--keep-going` exist on `cargo test` and `cargo bench` but with slightly different behavior. The intended use cases for `--keep-going` involve build commands like `build`/`check`/`clippy` but never `test`/`bench`. Hence, this commit removes `--keep-going` from `test`/`bench` and provides guidance of `--no-fail-fast` instead. If people really want to build as many tests as possible, they can also do it in two steps: cargo build --tests --keep-going cargo test --test --no-fail-fast
1 parent 7da1030 commit 5ae529b

File tree

11 files changed

+71
-30
lines changed

11 files changed

+71
-30
lines changed

src/bin/cargo/commands/bench.rs

Lines changed: 13 additions & 1 deletion
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

Lines changed: 12 additions & 1 deletion
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

Lines changed: 10 additions & 7 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 5 deletions
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

Lines changed: 0 additions & 6 deletions
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/man/cargo-test.1

Lines changed: 0 additions & 7 deletions
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

Lines changed: 18 additions & 0 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

0 commit comments

Comments
 (0)