diff --git a/nextest-runner/src/reporter/displayer.rs b/nextest-runner/src/reporter/displayer.rs index 94a0baf2754..1d843373290 100644 --- a/nextest-runner/src/reporter/displayer.rs +++ b/nextest-runner/src/reporter/displayer.rs @@ -1481,7 +1481,7 @@ impl<'a> TestReporterImpl<'a> { writer.write_all(&output.buf[..start])?; writer.write_all(RESET_COLOR)?; - write!(writer, "{}", FmtPrefix(&self.styles.count))?; + write!(writer, "{}", FmtPrefix(&self.styles.fail))?; // Strip ANSI escapes from this part of the output. It's unlikely there are any, but // strip it just in case. @@ -1489,7 +1489,7 @@ impl<'a> TestReporterImpl<'a> { no_color.write_all(&output.buf[start..end])?; let writer = no_color.into_inner()?; - write!(writer, "{}", FmtSuffix(&self.styles.count))?; + write!(writer, "{}", FmtSuffix(&self.styles.fail))?; // `end` is guaranteed to be within the bounds of `output.buf`. (It is actually safe // for it to be equal to `output.buf.len()` -- it gets treated as an empty list in diff --git a/nextest-runner/src/reporter/helpers.rs b/nextest-runner/src/reporter/helpers.rs index 49a20337b31..86910f1c8a9 100644 --- a/nextest-runner/src/reporter/helpers.rs +++ b/nextest-runner/src/reporter/helpers.rs @@ -210,7 +210,9 @@ fn heuristic_should_panic(stdout: &[u8]) -> Option> { } fn heuristic_panic_message(stderr: &[u8]) -> Option> { - let panicked_at_match = PANICKED_AT_REGEX.find(stderr)?; + // Look for the last instance to handle situations like proptest which repeatedly print out + // `panicked at ...` messages. + let panicked_at_match = PANICKED_AT_REGEX.find_iter(stderr).last()?; // If the previous line starts with "Error: ", grab it as well -- it contains the error with // result-based test failures. let mut start = panicked_at_match.start(); @@ -300,7 +302,7 @@ test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 13 filtered out; } #[test] - fn test_heuristic_stack_trace() { + fn test_heuristic_panic_message() { let tests: &[(&str, &str)] = &[ ( "thread 'main' panicked at 'foo', src/lib.rs:1\n", @@ -330,7 +332,17 @@ thread 'test_result_failure' panicked at 'assertion failed: `(left == right)` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace more text at the end, followed by some newlines"#, ), - // With RUST_BACKTRACE=1 + // Multiple panics: only the last one should be extracted. + ( + r#" +thread 'main' panicked at src/lib.rs:1: +foo +thread 'main' panicked at src/lib.rs:2: +bar +"#, + r#"thread 'main' panicked at src/lib.rs:2: +bar"#, + ), // With RUST_BACKTRACE=1 ( r#" some initial text