Repository: Canop/bacon (language: rust)

Issue:
Show failure location in summary
It would be nice to be able to keep the file location in the summary view so that it's easy to jump to the location of the failing test (I often run tests in VSCode terminal, which accepts Cmd+Click to jump to a line of code)

Normal view
```
 1  failed: tests::test1
 thread 'tests::test1' panicked at src/lib.rs:123:9:
 assertion failed: false
```

Summary view
```
 1  failed: tests::automatically
```




Discussion / hints:
This looks like a bug that I don't reproduce right now: in my test the location line is correctly recognized and displayed in summary mode.

Can you please provide a test case ?

(also please check you have the last version)
I installed the latest available version just now:
```
❯ bacon --version
bacon 2.21.0
```
`cargo new bacon-test --lib`
```rust
#[cfg(test)]
mod tests {

    #[test]
    fn test1() {
        assert!(false);
    }
}
```

default:
<img width="1840" alt="image" src="https://github.com/user-attachments/assets/cea71744-beb0-438e-8cf1-38a02bad3830">

Press s for summary:
<img width="1840" alt="image" src="https://github.com/user-attachments/assets/9ce75a16-ab0b-4010-b3e8-a4519c5e346c">

In case it wasn't clear, by file location, I meant `src/lib.rs:6:9`, not `tests:test1` as the latter does not (yet) work with vscode / rust-analyzer to navigate to tests. Also this is a nice to have / papercut type issue, not a breaking the world type one.
Thanks, I reproduce. And indeed it's not a location line (as defined in the bacon model) so not really a bug, but something I hadn't thought about.

I'll have a look.

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e3e87e1..4b8c58d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,6 @@
 ### next
 - new `exports` structure in configuration. New `analysis` export bound by default to `ctrl-e`. The old syntax defining locations export is still supported but won't appear in documentations anymore.
+- recognize panic location in test - Fix #208
 
 <a name="v2.21.0"></a>
 ### v2.21.0 - 2024/09/14
diff --git a/src/line_analysis.rs b/src/line_analysis.rs
index a0eff79..b6573ff 100644
--- a/src/line_analysis.rs
+++ b/src/line_analysis.rs
@@ -44,6 +44,9 @@ impl From<&CommandOutputLine> for LineAnalysis {
             } else if regex_is_match!(r#"^\s+--> [^:\s'"]+:\d+:\d+$"#, content) {
                 // this comes up in test failures to compile
                 LineType::Location
+            } else if regex_is_match!(r#"^thread '.+' panicked at [^:\s'"]+:\d+:\d+:$"#, content) {
+                // this comes up in test failures
+                LineType::Location
             } else {
                 LineType::Normal
             }


Test patch:
diff --git a/tests/standard_line_analysis/failure-location-issue-208.json b/tests/standard_line_analysis/failure-location-issue-208.json
new file mode 100644
index 0000000..563ae6f
--- /dev/null
+++ b/tests/standard_line_analysis/failure-location-issue-208.json
@@ -0,0 +1,63 @@
+{
+  "lines": [
+    {
+      "line": {
+        "content": {
+          "strings": [
+            {
+              "csi": "",
+              "raw": "test tests::test1 ... "
+            },
+            {
+              "csi": "\u001b[31m",
+              "raw": "FAILED"
+            }
+          ]
+        },
+        "origin": "StdOut"
+      },
+      "analysis": {
+        "line_type": {
+          "TestResult": false
+        },
+        "key": "tests::test1"
+      }
+    },
+    {
+      "line": {
+        "content": {
+          "strings": [
+            {
+              "csi": "",
+              "raw": "---- tests::test1 stdout ----"
+            }
+          ]
+        },
+        "origin": "StdOut"
+      },
+      "analysis": {
+        "line_type": {
+          "Title": "TestFail"
+        },
+        "key": "tests::test1"
+      }
+    },
+    {
+      "line": {
+        "content": {
+          "strings": [
+            {
+              "csi": "",
+              "raw": "thread 'tests::test1' panicked at src/lib.rs:6:9:"
+            }
+          ]
+        },
+        "origin": "StdOut"
+      },
+      "analysis": {
+        "line_type": "Location",
+        "key": null
+      }
+    }
+  ]
+}