Repository: Canop/bacon (language: rust)

Issue:
Failing test reported as passing given stack overflow, at least one passing test, and a compiler warning
Run `bacon test` on a cargo project containing the following code

```rust
fn a_warning() {}

#[test]
fn another_test() {}

#[test]
fn test() { 
    if 1 == 1 {
        test()
    }
}
```

It outputs

```
proj-name   test   pass!    1 warning   

1  warning: function `a_warning` is never used
--> src/lib.rs:1:4
 |
1 | fn a_warning() {}
 |    ^^^^^^^^^
 |
 = note: `#[warn(dead_code)]` on by default
```

Despite the fact that `cargo test` reports

```
warning: function `a_warning` is never used
 --> src/lib.rs:1:4
  |
1 | fn a_warning() {}
  |    ^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: `overflow` (lib) generated 1 warning
warning: `overflow` (lib test) generated 1 warning (1 duplicate)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.00s
     Running unittests src/lib.rs (target/debug/deps/overflow-b0e0b11f646c1cda)

running 2 tests
test another_test ... ok

thread 'test' has overflowed its stack
fatal runtime error: stack overflow
error: test failed, to rerun pass `--lib`

Caused by:
  process didn't exit successfully: `/tmp/overflow/target/debug/deps/overflow-b0e0b11f646c1cda` (signal: 6, SIGABRT: process abort signal)
```

Changing `1 == 1` to `1 == 2` makes the test pass, but doesn't change bacon's output at all since it reports it as it if was already passing.


Discussion / hints:

Fix patch:
diff --git a/src/analysis/standard/standard_line_analyser.rs b/src/analysis/standard/standard_line_analyser.rs
index d6bf152..6bcb943 100644
--- a/src/analysis/standard/standard_line_analyser.rs
+++ b/src/analysis/standard/standard_line_analyser.rs
@@ -33,6 +33,9 @@ fn analyze_line(cmd_line: &CommandOutputLine) -> LineAnalysis {
         } else if let Some(k) = as_fail_result_title(content) {
             key = Some(k.to_string());
             LineType::Title(Kind::TestFail)
+        } else if let Some(k) = as_stack_overflow_message(content) {
+            key = Some(k.to_string());
+            LineType::Title(Kind::TestFail)
         } else if cmd_line.origin == CommandStream::StdErr
             && regex_is_match!("^error: ", content)
             && !regex_is_match!("^error: aborting due to", content)
@@ -212,3 +215,9 @@ fn as_test_result(s: &str) -> Option<(&str, bool)> {
 fn as_fail_result_title(s: &str) -> Option<&str> {
     regex_captures!(r#"^---- (.+) stdout ----$"#, s).map(|(_, key)| key)
 }
+
+/// Returns Some(key) when the line is like this:
+/// thread 'key' has overflowed its stack
+fn as_stack_overflow_message(s: &str) -> Option<&str> {
+    regex_captures!("^thread '(.+)' has overflowed its stack$", s).map(|(_, key)| key)
+}


Test patch: