Repository: cpisciotta/xcbeautify (swift)

Issue:
[New Output] Support SwiftDriver Compilation Requirements Output
### What's the uncaptured output?

```
SwiftDriver\ Compilation\ Requirements SomeTarget normal arm64 com.apple.xcode.tools.swift.compiler (in target 'Target' from project 'Project')
    cd /path/to/some/package
    builtin-Swift-Compilation-Requirements -- /Applications/Xcode-15.0.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc ...
```

### Suggested Regex

_No response_

### Suggested Output

_No response_

### Additional Context

_No response_

Pull request:
Fixes #213

Patch:
diff --git a/Sources/XcbeautifyLib/CaptureGroups.swift b/Sources/XcbeautifyLib/CaptureGroups.swift
index 318fa81b..b376a92a 100644
--- a/Sources/XcbeautifyLib/CaptureGroups.swift
+++ b/Sources/XcbeautifyLib/CaptureGroups.swift
@@ -2154,3 +2154,17 @@ struct SwiftDriverCompilationTarget: CaptureGroup {
         self.target = target
     }
 }
+
+struct SwiftDriverCompilationRequirementsCaptureGroup: CaptureGroup {
+    static let outputType: OutputType = .task
+
+    static let regex = Regex(pattern: #"^SwiftDriver\\ Compilation\\ Requirements (.*) normal (?:arm64|x86_64) com\.apple\.xcode\.tools\.swift\.compiler"#)
+
+    let target: String
+
+    init?(groups: [String]) {
+        assert(groups.count == 1)
+        guard let target = groups[safe: 0] else { return nil }
+        self.target = target
+    }
+}
diff --git a/Sources/XcbeautifyLib/Formatter.swift b/Sources/XcbeautifyLib/Formatter.swift
index 8ed51ccd..fd258fc2 100644
--- a/Sources/XcbeautifyLib/Formatter.swift
+++ b/Sources/XcbeautifyLib/Formatter.swift
@@ -242,6 +242,8 @@ package struct Formatter {
             return renderer.formatSwiftTestingPassingArgument(group: group)
         case let group as SwiftDriverCompilationTarget:
             return renderer.formatSwiftDriverCompilationTarget(group: group)
+        case let group as SwiftDriverCompilationRequirementsCaptureGroup:
+            return renderer.formatSwiftDriverCompilationRequirements(group: group)
         default:
             assertionFailure()
             return nil
diff --git a/Sources/XcbeautifyLib/Parser.swift b/Sources/XcbeautifyLib/Parser.swift
index f933c84b..a6bc8fe9 100644
--- a/Sources/XcbeautifyLib/Parser.swift
+++ b/Sources/XcbeautifyLib/Parser.swift
@@ -117,6 +117,7 @@ package final class Parser {
         SwiftTestingIssueArgumentCaptureGroup.self,
         SwiftTestingPassingArgumentCaptureGroup.self,
         SwiftDriverCompilationTarget.self,
+        SwiftDriverCompilationRequirementsCaptureGroup.self,
     ]
 
     // MARK: - Init
diff --git a/Sources/XcbeautifyLib/Renderers/OutputRendering.swift b/Sources/XcbeautifyLib/Renderers/OutputRendering.swift
index 319fc385..839cbe15 100644
--- a/Sources/XcbeautifyLib/Renderers/OutputRendering.swift
+++ b/Sources/XcbeautifyLib/Renderers/OutputRendering.swift
@@ -651,4 +651,8 @@ extension OutputRendering {
     func formatSwiftDriverCompilationTarget(group: SwiftDriverCompilationTarget) -> String? {
         nil
     }
+
+    func formatSwiftDriverCompilationRequirements(group: SwiftDriverCompilationRequirementsCaptureGroup) -> String? {
+        nil
+    }
 }


Test patch:
diff --git a/Tests/XcbeautifyLibTests/ParserTests.swift b/Tests/XcbeautifyLibTests/ParserTests.swift
index a86a4368..b534cf87 100644
--- a/Tests/XcbeautifyLibTests/ParserTests.swift
+++ b/Tests/XcbeautifyLibTests/ParserTests.swift
@@ -181,4 +181,10 @@ final class ParserTests: XCTestCase {
         let captureGroup = try XCTUnwrap(parser.parse(line: input) as? SwiftDriverCompilationTarget)
         XCTAssertEqual(captureGroup.target, "SomeTarget")
     }
+
+    func testSwiftDriverCompilationRequirementsCaptureGroup() throws {
+        let input = #"SwiftDriver\ Compilation\ Requirements Backyard\ Birds normal arm64 com.apple.xcode.tools.swift.compiler (in target 'Backyard Birds' from project 'Backyard Birds')"#
+        let captureGroup = try XCTUnwrap(parser.parse(line: input) as? SwiftDriverCompilationRequirementsCaptureGroup)
+        XCTAssertEqual(captureGroup.target, #"Backyard\ Birds"#)
+    }
 }
diff --git a/Tests/XcbeautifyLibTests/ParsingTests/ParsingTests.swift b/Tests/XcbeautifyLibTests/ParsingTests/ParsingTests.swift
index cfa29454..7159a130 100644
--- a/Tests/XcbeautifyLibTests/ParsingTests/ParsingTests.swift
+++ b/Tests/XcbeautifyLibTests/ParsingTests/ParsingTests.swift
@@ -26,9 +26,9 @@ final class ParsingTests: XCTestCase {
         // Update this magic number whenever `uncapturedOutput` is less than the current magic number.
         // There's a regression whenever `uncapturedOutput` is greater than the current magic number.
         #if os(macOS)
-        XCTAssertEqual(uncapturedOutput, 245)
+        XCTAssertEqual(uncapturedOutput, 235)
         #else
-        XCTAssertEqual(uncapturedOutput, 261)
+        XCTAssertEqual(uncapturedOutput, 251)
         #endif
     }
 
@@ -56,9 +56,9 @@ final class ParsingTests: XCTestCase {
         // Update this magic number whenever `uncapturedOutput` is less than the current magic number.
         // There's a regression whenever `uncapturedOutput` is greater than the current magic number.
         #if os(macOS)
-        XCTAssertEqual(uncapturedOutput, 8167)
+        XCTAssertEqual(uncapturedOutput, 7808)
         #else
-        XCTAssertEqual(uncapturedOutput, 8735)
+        XCTAssertEqual(uncapturedOutput, 8376)
         #endif
     }
 
diff --git a/Tests/XcbeautifyLibTests/RendererTests/TerminalRendererTests.swift b/Tests/XcbeautifyLibTests/RendererTests/TerminalRendererTests.swift
index 23b84413..a2809c07 100644
--- a/Tests/XcbeautifyLibTests/RendererTests/TerminalRendererTests.swift
+++ b/Tests/XcbeautifyLibTests/RendererTests/TerminalRendererTests.swift
@@ -711,4 +711,9 @@ final class TerminalRendererTests: XCTestCase {
         let input = #"SwiftDriver\ Compilation SomeTarget normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'Target' from project 'Project')"#
         XCTAssertNil(noColoredFormatted(input))
     }
+
+    func testSwiftDriverCompilationRequirements() throws {
+        let input = #"SwiftDriver\ Compilation\ Requirements Backyard\ Birds normal arm64 com.apple.xcode.tools.swift.compiler (in target 'Backyard Birds' from project 'Backyard Birds')"#
+        XCTAssertNil(noColoredFormatted(input))
+    }
 }