Skip to content

Commit

Permalink
Remove Execs::run_expect_error to avoid rust-lang#14060
Browse files Browse the repository at this point in the history
  • Loading branch information
choznerol committed Jun 15, 2024
1 parent 36b44ed commit 0a20aab
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
9 changes: 0 additions & 9 deletions crates/cargo-test-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,15 +915,6 @@ impl Execs {
}
}

#[track_caller]
pub fn run_expect_error(&mut self) {
self.ran = true;
let p = (&self.process_builder).clone().unwrap();
if self.match_process(&p).is_ok() {
panic!("test was expected to fail, but succeeded running {}", p);
}
}

/// Runs the process, checks the expected output, and returns the first
/// JSON object on stdout.
#[track_caller]
Expand Down
3 changes: 2 additions & 1 deletion tests/testsuite/check_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,10 +632,11 @@ fn config_invalid_empty() {
.build();

p.cargo("check")
.with_status(101)
.with_stderr_contains(
"[..]missing field `level`[..] THIS RANDOM SENTENCE SHOULD FAIL THIS TEST BUT DIDN'T",
)
.run_expect_error();
.run();
}

#[cargo_test(>=1.79, reason = "--check-cfg was stabilized in Rust 1.79")]
Expand Down
3 changes: 2 additions & 1 deletion tests/testsuite/freshness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2933,6 +2933,7 @@ fn use_mtime_cache_in_cargo_home() {
p.change_file("src/lib.rs", "illegal syntax");
p.cargo("check -v")
.env("CARGO_HOME", &cargo_home)
.with_status(101)
.with_stderr(
"\
[DIRTY] foo v0.5.0 ([CWD]): [..]
Expand All @@ -2942,5 +2943,5 @@ fn use_mtime_cache_in_cargo_home() {
[CHECKING] foo v0.5.0 ([CWD])
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]",
)
.run_expect_error();
.run();
}
3 changes: 2 additions & 1 deletion tests/testsuite/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,10 @@ fn help_alias() {
// The `empty-alias` returns an error.
cargo_process("help empty-alias")
.env("PATH", Path::new(""))
.with_status(101)
.with_stderr_contains("THIS RANDOM SENTENCE SHOULD FAIL THIS TEST BUT DIDN'T [..] The subcommand 'empty-alias' wasn't recognized [..]",
)
.run_expect_error();
.run();

// Because `simple-alias` aliases a subcommand with no arguments, help shows the manpage.
help_with_man_and_path("", "simple-alias", "build", Path::new(""));
Expand Down

0 comments on commit 0a20aab

Please sign in to comment.