Skip to content

Commit 5586a47

Browse files
committed
Auto merge of #14078 - choznerol:issue-14076-run_expect_error-test-incorrectly-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).
2 parents ea16f96 + 6ae78e8 commit 5586a47

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

crates/cargo-test-support/src/lib.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -915,15 +915,6 @@ impl Execs {
915915
}
916916
}
917917

918-
#[track_caller]
919-
pub fn run_expect_error(&mut self) {
920-
self.ran = true;
921-
let p = (&self.process_builder).clone().unwrap();
922-
if self.match_process(&p).is_ok() {
923-
panic!("test was expected to fail, but succeeded running {}", p);
924-
}
925-
}
926-
927918
/// Runs the process, checks the expected output, and returns the first
928919
/// JSON object on stdout.
929920
#[track_caller]

tests/testsuite/check_cfg.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,9 @@ fn config_invalid_empty() {
632632
.build();
633633

634634
p.cargo("check")
635+
.with_status(101)
635636
.with_stderr_contains("[..]missing field `level`[..]")
636-
.run_expect_error();
637+
.run();
637638
}
638639

639640
#[cargo_test(>=1.79, reason = "--check-cfg was stabilized in Rust 1.79")]

tests/testsuite/freshness.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2933,11 +2933,12 @@ fn use_mtime_cache_in_cargo_home() {
29332933
p.change_file("src/lib.rs", "illegal syntax");
29342934
p.cargo("check -v")
29352935
.env("CARGO_HOME", &cargo_home)
2936-
.with_stderr(
2936+
.with_status(101)
2937+
.with_stderr_contains(
29372938
"\
29382939
[DIRTY] foo v0.5.0 ([CWD]): [..]
29392940
[CHECKING] foo v0.5.0 ([CWD])
29402941
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]",
29412942
)
2942-
.run_expect_error();
2943+
.run();
29432944
}

0 commit comments

Comments
 (0)