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 SwiftDriverCompilationTarget #321

Merged
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 @@ -2140,3 +2140,17 @@ struct SwiftTestingPassingArgumentCaptureGroup: CaptureGroup {
self.numberOfArguments = numberOfArguments
}
}

struct SwiftDriverCompilationTarget: CaptureGroup {
static let outputType: OutputType = .task

static let regex = Regex(pattern: #"^SwiftDriver\\ Compilation (.*) 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
}
}
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 SwiftDriverCompilationTarget:
return renderer.formatSwiftDriverCompilationTarget(group: group)
default:
assertionFailure()
return nil
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,
SwiftDriverCompilationTarget.self,
]

// MARK: - Init
Expand Down
5 changes: 5 additions & 0 deletions Sources/XcbeautifyLib/Renderers/OutputRendering.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ protocol OutputRendering {
func formatSwiftTestingIssue(group: SwiftTestingIssueCaptureGroup) -> String
func formatSwiftTestingIssueArguments(group: SwiftTestingIssueArgumentCaptureGroup) -> String
func formatSwiftTestingPassingArgument(group: SwiftTestingPassingArgumentCaptureGroup) -> String?
func formatSwiftDriverCompilationTarget(group: SwiftDriverCompilationTarget) -> String?
}

extension OutputRendering {
Expand Down Expand Up @@ -646,4 +647,8 @@ extension OutputRendering {
func formatSwiftTestingPassingArgument(group: SwiftTestingPassingArgumentCaptureGroup) -> String? {
nil
}

func formatSwiftDriverCompilationTarget(group: SwiftDriverCompilationTarget) -> String? {
nil
}
}
6 changes: 6 additions & 0 deletions Tests/XcbeautifyLibTests/ParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,10 @@ final class ParserTests: XCTestCase {
let captureGroup = try XCTUnwrap(parser.parse(line: input) as? SwiftTestingPassingArgumentCaptureGroup)
XCTAssertEqual(captureGroup.numberOfArguments, 2)
}

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)
XCTAssertEqual(captureGroup.target, "SomeTarget")
}
}
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, 255)
XCTAssertEqual(uncapturedOutput, 245)
#else
XCTAssertEqual(uncapturedOutput, 271)
XCTAssertEqual(uncapturedOutput, 261)
#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, 8519)
XCTAssertEqual(uncapturedOutput, 8167)
#else
XCTAssertEqual(uncapturedOutput, 9087)
XCTAssertEqual(uncapturedOutput, 8735)
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,4 +706,9 @@ final class TerminalRendererTests: XCTestCase {
let output = #" [!] Test "myTest" recorded an issue at PlanTests.swift:43:5: Expectation failed"#
XCTAssertEqual(noColoredFormatted(input), output)
}

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))
}
}