Skip to content

feat: remove --keep-going from cargo test/bench #12478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 13 additions & 1 deletion src/bin/cargo/commands/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ pub fn cli() -> Command {
"Benchmark all targets",
)
.arg_features()
.arg_jobs()
.arg_jobs_without_keep_going()
.arg(flag("keep-going", "Use `--no-fail-fast` instead").hide(true)) // See rust-lang/cargo#11702
.arg_profile("Build artifacts with the specified profile")
.arg_target_triple("Build for the target triple")
.arg_target_dir()
Expand All @@ -54,6 +55,17 @@ pub fn cli() -> Command {

pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
let ws = args.workspace(config)?;

if args.keep_going() {
return Err(anyhow::format_err!(
"\
unexpected argument `--keep-going` found

tip: to run as many benchmarks as possible without failing fast, use `--no-fail-fast`"
)
.into());
}

let mut compile_opts = args.compile_options(
config,
CompileMode::Bench,
Expand Down
13 changes: 12 additions & 1 deletion src/bin/cargo/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ pub fn cli() -> Command {
"Test all targets (does not include doctests)",
)
.arg_features()
.arg_jobs()
.arg_jobs_without_keep_going()
.arg(flag("keep-going", "Use `--no-fail-fast` instead").hide(true)) // See rust-lang/cargo#11702
.arg_release("Build artifacts in release mode, with optimizations")
.arg_profile("Build artifacts with the specified profile")
.arg_target_triple("Build for the target triple")
Expand All @@ -65,6 +66,16 @@ pub fn cli() -> Command {
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
let ws = args.workspace(config)?;

if args.keep_going() {
return Err(anyhow::format_err!(
"\
unexpected argument `--keep-going` found

tip: to run as many tests as possible without failing fast, use `--no-fail-fast`"
)
.into());
}

let mut compile_opts = args.compile_options(
config,
CompileMode::Test,
Expand Down
17 changes: 10 additions & 7 deletions src/cargo/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,23 @@ pub trait CommandExt: Sized {
}

fn arg_jobs(self) -> Self {
self.arg_jobs_without_keep_going()._arg(
flag(
"keep-going",
"Do not abort the build as soon as there is an error (unstable)",
)
.help_heading(heading::COMPILATION_OPTIONS),
)
}

fn arg_jobs_without_keep_going(self) -> Self {
self._arg(
opt("jobs", "Number of parallel jobs, defaults to # of CPUs.")
.short('j')
.value_name("N")
.allow_hyphen_values(true)
.help_heading(heading::COMPILATION_OPTIONS),
)
._arg(
flag(
"keep-going",
"Do not abort the build as soon as there is an error (unstable)",
)
.help_heading(heading::COMPILATION_OPTIONS),
)
}

fn arg_targets_all(
Expand Down
1 change: 0 additions & 1 deletion src/doc/man/cargo-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ includes an option to control the number of threads used:
{{#options}}

{{> options-jobs }}
{{> options-keep-going }}
{{> options-future-incompat }}

{{/options}}
Expand Down
5 changes: 0 additions & 5 deletions src/doc/man/generated_txt/cargo-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,6 @@ OPTIONS
If a string default is provided, it sets the value back to defaults.
Should not be 0.

--keep-going
Build as many crates in the dependency graph as possible, rather
than aborting the build on the first one that fails to build.
Unstable, requires -Zunstable-options.

--future-incompat-report
Displays a future-incompat report for any future-incompatible
warnings produced during execution of this command
Expand Down
6 changes: 0 additions & 6 deletions src/doc/src/commands/cargo-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -515,12 +515,6 @@ a string <code>default</code> is provided, it sets the value back to defaults.
Should not be 0.</dd>


<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>
<dd class="option-desc">Build as many crates in the dependency graph as possible, rather than aborting
the build on the first one that fails to build. Unstable, requires
<code>-Zunstable-options</code>.</dd>


<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>
<dd class="option-desc">Displays a future-incompat report for any future-incompatible warnings
produced during execution of this command</p>
Expand Down
7 changes: 0 additions & 7 deletions src/etc/man/cargo-test.1
Original file line number Diff line number Diff line change
Expand Up @@ -535,13 +535,6 @@ a string \fBdefault\fR is provided, it sets the value back to defaults.
Should not be 0.
.RE
.sp
\fB\-\-keep\-going\fR
.RS 4
Build as many crates in the dependency graph as possible, rather than aborting
the build on the first one that fails to build. Unstable, requires
\fB\-Zunstable\-options\fR\&.
.RE
.sp
\fB\-\-future\-incompat\-report\fR
.RS 4
Displays a future\-incompat report for any future\-incompatible warnings
Expand Down
18 changes: 18 additions & 0 deletions tests/testsuite/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1670,3 +1670,21 @@ fn json_artifact_includes_executable_for_benchmark() {
)
.run();
}

#[cargo_test]
fn cargo_bench_no_keep_going() {
let p = project()
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/main.rs", "")
.build();

p.cargo("bench --keep-going")
.with_stderr(
"\
error: unexpected argument `--keep-going` found

tip: to run as many benchmarks as possible without failing fast, use `--no-fail-fast`",
)
.with_status(101)
.run();
}
1 change: 0 additions & 1 deletion tests/testsuite/cargo_bench/help/stdout.log
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ Feature Selection:

Compilation Options:
-j, --jobs <N> Number of parallel jobs, defaults to # of CPUs.
--keep-going Do not abort the build as soon as there is an error (unstable)
--profile <PROFILE-NAME> Build artifacts with the specified profile
--target <TRIPLE> Build for the target triple
--target-dir <DIRECTORY> Directory for all generated artifacts
Expand Down
1 change: 0 additions & 1 deletion tests/testsuite/cargo_test/help/stdout.log
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ Feature Selection:

Compilation Options:
-j, --jobs <N> Number of parallel jobs, defaults to # of CPUs.
--keep-going Do not abort the build as soon as there is an error (unstable)
-r, --release Build artifacts in release mode, with optimizations
--profile <PROFILE-NAME> Build artifacts with the specified profile
--target <TRIPLE> Build for the target triple
Expand Down
18 changes: 18 additions & 0 deletions tests/testsuite/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4843,3 +4843,21 @@ error: 2 targets failed:
.with_status(101)
.run();
}

#[cargo_test]
fn cargo_test_no_keep_going() {
let p = project()
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/main.rs", "")
.build();

p.cargo("test --keep-going")
.with_stderr(
"\
error: unexpected argument `--keep-going` found

tip: to run as many tests as possible without failing fast, use `--no-fail-fast`",
)
.with_status(101)
.run();
}