Repository: cpisciotta/xcbeautify
Pull request #375 (2025-02-11 02:48:07)

Fix SwiftTestingTestStartedCaptureGroup Matching

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/cpisciotta/xcbeautify/pull/375?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Charles+Pisciotta) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 91.31%. Comparing base [(`23e7ccd`)](https://app.codecov.io/gh/cpisciotta/xcbeautify/commit/23e7ccd0193515134c66a2b097334796a7d13c1b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Charles+Pisciotta) to head [(`40972a8`)](https://app.codecov.io/gh/cpisciotta/xcbeautify/commit/40972a850e3ac0c3d75153b2e6c6d03823564cdd?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Charles+Pisciotta).

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##             main     #375   +/-   ##
=======================================
  Coverage   91.31%   91.31%           
=======================================
  Files          17       17           
  Lines        2441     2441           
=======================================
  Hits         2229     2229           
  Misses        212      212           
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/cpisciotta/xcbeautify/pull/375?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Charles+Pisciotta).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Charles+Pisciotta).


Patch:
diff --git a/Sources/XcbeautifyLib/CaptureGroups.swift b/Sources/XcbeautifyLib/CaptureGroups.swift
index c93dc6f..11c538b 100644
--- a/Sources/XcbeautifyLib/CaptureGroups.swift
+++ b/Sources/XcbeautifyLib/CaptureGroups.swift
@@ -2067,7 +2067,7 @@ struct SwiftTestingTestStartedCaptureGroup: CaptureGroup {
 
     /// Regular expression to capture the start of a test case.
     /// $1 = test name
-    static let regex = XCRegex(pattern: #"^􀟈  Test\s+(.*) started\.$"#)
+    static let regex = XCRegex(pattern: #"^􀟈  Test (?!run )(.*) started\.$"#)
 
     let testName: String
     let wholeMessage: String


Test patch:
diff --git a/Tests/XcbeautifyLibTests/CaptureGroupTests.swift b/Tests/XcbeautifyLibTests/CaptureGroupTests.swift
index aeb0d70..e7dd339 100644
--- a/Tests/XcbeautifyLibTests/CaptureGroupTests.swift
+++ b/Tests/XcbeautifyLibTests/CaptureGroupTests.swift
@@ -163,4 +163,22 @@ final class CaptureGroupTests: XCTestCase {
         let input = #"/Users/andres/Git/xcbeautify/Tests/XcbeautifyLibTests/XcbeautifyLibTests.swift:13: error: -[XcbeautifyLibTests.XcbeautifyLibTests testAggregateTarget] : XCTAssertEqual failed: ("Optional("Aggregate target Be Aggro of project AggregateExample with configuration Debug")") is not equal to ("Optional("failing Aggregate target Be Aggro of project AggregateExample with configuration Debug")")"#
         XCTAssertNil(CompileErrorCaptureGroup.regex.captureGroups(for: input))
     }
+
+    func testMatchSwiftTestingTestRunStarted() {
+        let input = "􀟈  Test run started."
+        XCTAssertNil(SwiftTestingTestStartedCaptureGroup.regex.captureGroups(for: input))
+        XCTAssertNotNil(SwiftTestingRunStartedCaptureGroup.regex.captureGroups(for: input))
+    }
+
+    func testMatchSwiftTestingTestStarted() {
+        let input = #"􀟈  Test "One Identifiable parameter" started."#
+        XCTAssertNotNil(SwiftTestingTestStartedCaptureGroup.regex.captureGroups(for: input))
+        XCTAssertNil(SwiftTestingRunStartedCaptureGroup.regex.captureGroups(for: input))
+    }
+
+    func testMatchTestCaseWithRunInName() {
+        let input = "􀟈  Test runnerStateScopedEventHandler() started."
+        XCTAssertNotNil(SwiftTestingTestStartedCaptureGroup.regex.captureGroups(for: input))
+        XCTAssertNil(SwiftTestingRunStartedCaptureGroup.regex.captureGroups(for: input))
+    }
 }