Skip to content

Commit

Permalink
Auto merge of #14078 - choznerol:issue-14076-run_expect_error-test-in…
Browse files Browse the repository at this point in the history
…correctly-passing, r=weihanglo

Remove `run_expect_error` to avoid tests incorrectly passing

### What does this PR try to resolve?

Fixes #14076

### How should we test and review this PR?

I pushed commits separately so the CI status can show the reproduction and the fix:

- bc5d57c reproduce the bug: Its CI shouldn't have passed.
- 3c473b5 fixes the issue, so the CI for d9d11c4 is now correctly [failing tests](https://github.com/rust-lang/cargo/actions/runs/9529301554/job/26267905188#step:11:4072).
- Turns out these test already have regression. 79a7bf4 fixes them.

### Additional information

Thanks `@weihanglo` for suggesting the fix 3c473b5 in #14076 (comment).
  • Loading branch information
bors committed Jun 16, 2024
2 parents ea16f96 + 6ae78e8 commit 5586a47
Show file tree
Hide file tree
Showing 3 changed files with 5 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,8 +632,9 @@ fn config_invalid_empty() {
.build();

p.cargo("check")
.with_status(101)
.with_stderr_contains("[..]missing field `level`[..]")
.run_expect_error();
.run();
}

#[cargo_test(>=1.79, reason = "--check-cfg was stabilized in Rust 1.79")]
Expand Down
5 changes: 3 additions & 2 deletions tests/testsuite/freshness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2933,11 +2933,12 @@ 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_stderr(
.with_status(101)
.with_stderr_contains(
"\
[DIRTY] foo v0.5.0 ([CWD]): [..]
[CHECKING] foo v0.5.0 ([CWD])
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]",
)
.run_expect_error();
.run();
}

0 comments on commit 5586a47

Please sign in to comment.