Skip to content

Commit

Permalink
test: move --keep-going suggestion match tests to UI tests
Browse files Browse the repository at this point in the history
We don't want to overly match to suggestion help from clap.
  • Loading branch information
weihanglo committed Aug 22, 2023
1 parent 4d09585 commit a31aaac
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 46 deletions.
23 changes: 0 additions & 23 deletions tests/testsuite/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1671,29 +1671,6 @@ 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: use `--no-fail-fast` to run as many tests as possible regardless of failure
Usage: cargo bench [OPTIONS] [BENCHNAME] [-- [args]...]
For more information, try '--help'.
",
)
.with_status(1)
.run();
}

#[cargo_test(nightly, reason = "bench")]
fn cargo_bench_print_env_verbose() {
let p = project()
Expand Down
1 change: 1 addition & 0 deletions tests/testsuite/cargo_bench/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
mod help;
mod no_keep_going;
3 changes: 3 additions & 0 deletions tests/testsuite/cargo_bench/no_keep_going/in/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[package]
name = "foo"
version = "0.1.0"
Empty file.
19 changes: 19 additions & 0 deletions tests/testsuite/cargo_bench/no_keep_going/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

#[cargo_test]
fn case() {
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;

snapbox::cmd::Command::cargo_ui()
.arg("bench")
.arg("--keep-going")
.current_dir(cwd)
.assert()
.code(1)
.stdout_matches_path(curr_dir!().join("stdout.log"))
.stderr_matches_path(curr_dir!().join("stderr.log"));
}
7 changes: 7 additions & 0 deletions tests/testsuite/cargo_bench/no_keep_going/stderr.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
error: unexpected argument '--keep-going' found

tip: use `--no-fail-fast` to run as many tests as possible regardless of failure

Usage: cargo bench [OPTIONS] [BENCHNAME] [-- [args]...]

For more information, try '--help'.
Empty file.
1 change: 1 addition & 0 deletions tests/testsuite/cargo_test/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
mod help;
mod no_keep_going;
3 changes: 3 additions & 0 deletions tests/testsuite/cargo_test/no_keep_going/in/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[package]
name = "foo"
version = "0.1.0"
Empty file.
19 changes: 19 additions & 0 deletions tests/testsuite/cargo_test/no_keep_going/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

#[cargo_test]
fn case() {
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;

snapbox::cmd::Command::cargo_ui()
.arg("test")
.arg("--keep-going")
.current_dir(cwd)
.assert()
.code(1)
.stdout_matches_path(curr_dir!().join("stdout.log"))
.stderr_matches_path(curr_dir!().join("stderr.log"));
}
7 changes: 7 additions & 0 deletions tests/testsuite/cargo_test/no_keep_going/stderr.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
error: unexpected argument '--keep-going' found

tip: use `--no-fail-fast` to run as many tests as possible regardless of failure

Usage: cargo test [OPTIONS] [TESTNAME] [-- [args]...]

For more information, try '--help'.
Empty file.
23 changes: 0 additions & 23 deletions tests/testsuite/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4844,29 +4844,6 @@ error: 2 targets failed:
.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: use `--no-fail-fast` to run as many tests as possible regardless of failure
Usage: cargo test [OPTIONS] [TESTNAME] [-- [args]...]
For more information, try '--help'.
",
)
.with_status(1)
.run();
}

#[cargo_test]
fn cargo_test_print_env_verbose() {
let p = project()
Expand Down

0 comments on commit a31aaac

Please sign in to comment.