Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement SwiftDriverTargetCaptureGroup #323

Merged
merged 1 commit into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Sources/XcbeautifyLib/CaptureGroups.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions Sources/XcbeautifyLib/Formatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions Sources/XcbeautifyLib/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ package final class Parser {
SwiftTestingIssueCaptureGroup.self,
SwiftTestingIssueArgumentCaptureGroup.self,
SwiftTestingPassingArgumentCaptureGroup.self,
SwiftDriverTargetCaptureGroup.self,
SwiftDriverCompilationTarget.self,
SwiftDriverCompilationRequirementsCaptureGroup.self,
]
Expand Down
4 changes: 4 additions & 0 deletions Sources/XcbeautifyLib/Renderers/OutputRendering.swift
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,10 @@ extension OutputRendering {
nil
}

func formatSwiftDriverTarget(group: SwiftDriverTargetCaptureGroup) -> String? {
nil
}

func formatSwiftDriverCompilationTarget(group: SwiftDriverCompilationTarget) -> String? {
nil
}
Expand Down
6 changes: 6 additions & 0 deletions Tests/XcbeautifyLibTests/ParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions Tests/XcbeautifyLibTests/ParsingTests/ParsingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down