Repository: cpisciotta/xcbeautify (swift)

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

```
SwiftDriver SomeTargetName normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'Target' from project 'Project')
    cd /path/to/DerivedData/SourcePackages/checkouts/SwiftPackage
    builtin-SwiftDriver -- /Applications/Xcode-15.0.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name SomeTargetName ...
```

### Suggested Regex

_No response_

### Suggested Output

_No response_

### Additional Context

_No response_

Pull request description:
Fixes #202

Patch:
diff --git a/Sources/XcbeautifyLib/CaptureGroups.swift b/Sources/XcbeautifyLib/CaptureGroups.swift
index b376a92a..9e4f2ed0 100644
--- a/Sources/XcbeautifyLib/CaptureGroups.swift
+++ b/Sources/XcbeautifyLib/CaptureGroups.swift
@@ -2141,6 +2141,20 @@ struct SwiftTestingPassingArgumentCaptureGroup: CaptureGroup {
     }
 }
 
+struct SwiftDriverTargetCaptureGroup: CaptureGroup {
+    static let outputType: OutputType = .task
+
+    static let regex = Regex(pattern: #"^SwiftDriver (.*) 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
+    }
+}
+
 struct SwiftDriverCompilationTarget: CaptureGroup {
     static let outputType: OutputType = .task
 
diff --git a/Sources/XcbeautifyLib/Formatter.swift b/Sources/XcbeautifyLib/Formatter.swift
index fd258fc2..46a9676d 100644
--- a/Sources/XcbeautifyLib/Formatter.swift
+++ b/Sources/XcbeautifyLib/Formatter.swift
@@ -240,6 +240,8 @@ package struct Formatter {
             return renderer.formatSwiftTestingIssueArguments(group: group)
         case let group as SwiftTestingPassingArgumentCaptureGroup:
             return renderer.formatSwiftTestingPassingArgument(group: group)
+        case let group as SwiftDriverTargetCaptureGroup:
+            return renderer.formatSwiftDriverTarget(group: group)
         case let group as SwiftDriverCompilationTarget:
             return renderer.formatSwiftDriverCompilationTarget(group: group)
         case let group as SwiftDriverCompilationRequirementsCaptureGroup:
diff --git a/Sources/XcbeautifyLib/Parser.swift b/Sources/XcbeautifyLib/Parser.swift
index a6bc8fe9..fce48f37 100644
--- a/Sources/XcbeautifyLib/Parser.swift
+++ b/Sources/XcbeautifyLib/Parser.swift
@@ -116,6 +116,7 @@ package final class Parser {
         SwiftTestingIssueCaptureGroup.self,
         SwiftTestingIssueArgumentCaptureGroup.self,
         SwiftTestingPassingArgumentCaptureGroup.self,
+        SwiftDriverTargetCaptureGroup.self,
         SwiftDriverCompilationTarget.self,
         SwiftDriverCompilationRequirementsCaptureGroup.self,
     ]
diff --git a/Sources/XcbeautifyLib/Renderers/OutputRendering.swift b/Sources/XcbeautifyLib/Renderers/OutputRendering.swift
index 839cbe15..0b319075 100644
--- a/Sources/XcbeautifyLib/Renderers/OutputRendering.swift
+++ b/Sources/XcbeautifyLib/Renderers/OutputRendering.swift
@@ -648,6 +648,10 @@ extension OutputRendering {
         nil
     }
 
+    func formatSwiftDriverTarget(group: SwiftDriverTargetCaptureGroup) -> String? {
+        nil
+    }
+
     func formatSwiftDriverCompilationTarget(group: SwiftDriverCompilationTarget) -> String? {
         nil
     }


Test patch:
diff --git a/Tests/XcbeautifyLibTests/ParserTests.swift b/Tests/XcbeautifyLibTests/ParserTests.swift
index b534cf87..8c7d6237 100644
--- a/Tests/XcbeautifyLibTests/ParserTests.swift
+++ b/Tests/XcbeautifyLibTests/ParserTests.swift
@@ -176,6 +176,12 @@ final class ParserTests: XCTestCase {
         XCTAssertEqual(captureGroup.numberOfArguments, 2)
     }
 
+    func testSwiftDriverTargetCaptureGroup() throws {
+        let input = #"SwiftDriver BackyardBirdsData normal arm64 com.apple.xcode.tools.swift.compiler (in target \'BackyardBirdsData\' from project \'BackyardBirdsData\')"#
+        let captureGroup = try XCTUnwrap(parser.parse(line: input) as? SwiftDriverTargetCaptureGroup)
+        XCTAssertEqual(captureGroup.target, "BackyardBirdsData")
+    }
+
     func testSwiftDriverCompilationTarget() throws {
         let input = #"SwiftDriver\ Compilation SomeTarget normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'Target' from project 'Project')"#
         let captureGroup = try XCTUnwrap(parser.parse(line: input) as? SwiftDriverCompilationTarget)
diff --git a/Tests/XcbeautifyLibTests/ParsingTests/ParsingTests.swift b/Tests/XcbeautifyLibTests/ParsingTests/ParsingTests.swift
index 7159a130..6ff7f985 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, 235)
+        XCTAssertEqual(uncapturedOutput, 225)
         #else
-        XCTAssertEqual(uncapturedOutput, 251)
+        XCTAssertEqual(uncapturedOutput, 241)
         #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, 7808)
+        XCTAssertEqual(uncapturedOutput, 7456)
         #else
-        XCTAssertEqual(uncapturedOutput, 8376)
+        XCTAssertEqual(uncapturedOutput, 8024)
         #endif
     }
 
diff --git a/Tests/XcbeautifyLibTests/RendererTests/TerminalRendererTests.swift b/Tests/XcbeautifyLibTests/RendererTests/TerminalRendererTests.swift
index a2809c07..270dffa7 100644
--- a/Tests/XcbeautifyLibTests/RendererTests/TerminalRendererTests.swift
+++ b/Tests/XcbeautifyLibTests/RendererTests/TerminalRendererTests.swift
@@ -707,6 +707,11 @@ final class TerminalRendererTests: XCTestCase {
         XCTAssertEqual(noColoredFormatted(input), output)
     }
 
+    func testSwiftDriverTarget() throws {
+        let input = #"SwiftDriver BackyardBirdsData normal arm64 com.apple.xcode.tools.swift.compiler (in target \'BackyardBirdsData\' from project \'BackyardBirdsData\')"#
+        XCTAssertNil(noColoredFormatted(input))
+    }
+
     func testSwiftDriverCompilationTarget() throws {
         let input = #"SwiftDriver\ Compilation SomeTarget normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'Target' from project 'Project')"#
         XCTAssertNil(noColoredFormatted(input))