Skip to content
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

Relax test assertions so they are more flexible #393

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Changes from all commits
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
24 changes: 17 additions & 7 deletions tests/tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,14 @@ fn run_with_crash() {
.env("RUST_BACKTRACE", "1")
.assert()
.stderr(
predicate::str::contains("thread '<unnamed>' panicked at")
predicate::str::contains("panicked at")
.and(predicate::str::contains("I'm afraid of number 7"))
.and(predicate::str::contains("ERROR: libFuzzer: deadly signal"))
.and(predicate::str::contains("run_with_crash::fail_fuzzing"))
.and(predicate::str::contains("libFuzzer: deadly signal"))
// XXX: Symbolication may or may not happen depending on what
// LLVM tools are on `$PATH`, so don't assert that we got the
// expected symbol name, even though ideally we should.
//
// .and(predicate::str::contains("run_with_crash::fail_fuzzing"))
.and(predicate::str::contains(
"────────────────────────────────────────────────────────────────────────────────\n\
\n\
Expand Down Expand Up @@ -375,10 +379,12 @@ fn run_without_sanitizer_with_crash() {
.env("RUST_BACKTRACE", "1")
.assert()
.stderr(
predicate::str::contains("thread '<unnamed>' panicked at")
predicate::str::contains("panicked at")
.and(predicate::str::contains("I'm afraid of number 7"))
.and(predicate::str::contains("ERROR: libFuzzer: deadly signal"))
.and(predicate::str::contains("run_without_sanitizer_with_crash::fail_fuzzing"))
.and(predicate::str::contains("libFuzzer: deadly signal"))
// XXX: See comment in `run_with_crash`.
//
// .and(predicate::str::contains("run_without_sanitizer_with_crash::fail_fuzzing"))
.and(predicate::str::contains(
"────────────────────────────────────────────────────────────────────────────────\n\
\n\
Expand Down Expand Up @@ -691,7 +697,11 @@ fn cmin() {
.arg("foo")
.assert()
.success();
assert_eq!(corpus_count(), 1);

// XXX: Ideally this would be `assert_eq!(corpus_count(), 1)` but that has
// started failing in newer `rustc` / libFuzzer combinations. Just assert
// that the corpus got smaller, at least.
assert!(corpus_count() < 5);
}

#[test]
Expand Down
Loading