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

Add ExplicitDependencyCaptureGroup #307

Merged
merged 1 commit into from
Aug 14, 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
16 changes: 16 additions & 0 deletions Sources/XcbeautifyLib/CaptureGroups.swift
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,22 @@ struct ExecutedWithSkippedCaptureGroup: ExecutedCaptureGroup {
}
}

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

static let regex = Regex(pattern: #"^[ \t]*➜ Explicit dependency on target '([^']+)' in project '([^']+)'$"#)

let target: String
let project: String

init?(groups: [String]) {
assert(groups.count == 2)
guard let target = groups[safe: 0], let project = groups[safe: 1] else { return nil }
self.target = target
self.project = project
}
}

struct FailingTestCaptureGroup: CaptureGroup {
static let outputType: OutputType = .error

Expand Down
2 changes: 2 additions & 0 deletions Sources/XcbeautifyLib/Formatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
return renderer.formatExecutedWithoutSkipped(group: group)
case let group as ExecutedWithSkippedCaptureGroup:
return renderer.formatExecutedWithSkipped(group: group)
case let group as ExplicitDependencyCaptureGroup:
return renderer.formatExplicitDependencyCaptureGroup(group: group)

Check warning on line 86 in Sources/XcbeautifyLib/Formatter.swift

View check run for this annotation

Codecov / codecov/patch

Sources/XcbeautifyLib/Formatter.swift#L86

Added line #L86 was not covered by tests
case let group as FailingTestCaptureGroup:
return renderer.formatFailingTest(group: group)
case let group as FatalErrorCaptureGroup:
Expand Down
1 change: 1 addition & 0 deletions Sources/XcbeautifyLib/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package final class Parser {
CopyPlistCaptureGroup.self,
CopyStringsCaptureGroup.self,
CpresourceCaptureGroup.self,
ExplicitDependencyCaptureGroup.self,
FailingTestCaptureGroup.self,
UIFailingTestCaptureGroup.self,
RestartingTestCaptureGroup.self,
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 @@ -28,6 +28,7 @@
func formatError(group: any ErrorCaptureGroup) -> String
func formatExecutedWithoutSkipped(group: ExecutedWithoutSkippedCaptureGroup) -> String
func formatExecutedWithSkipped(group: ExecutedWithSkippedCaptureGroup) -> String
func formatExplicitDependencyCaptureGroup(group: ExplicitDependencyCaptureGroup) -> String?
func formatFailingTest(group: FailingTestCaptureGroup) -> String
func formatFileMissingError(group: FileMissingErrorCaptureGroup) -> String
func formatGenerateCoverageData(group: GenerateCoverageDataCaptureGroup) -> String
Expand Down Expand Up @@ -155,6 +156,10 @@
group.wholeResult
}

func formatExplicitDependencyCaptureGroup(group: ExplicitDependencyCaptureGroup) -> String? {
nil

Check warning on line 160 in Sources/XcbeautifyLib/Renderers/OutputRendering.swift

View check run for this annotation

Codecov / codecov/patch

Sources/XcbeautifyLib/Renderers/OutputRendering.swift#L159-L160

Added lines #L159 - L160 were not covered by tests
}

func formatGenerateCoverageData(group: GenerateCoverageDataCaptureGroup) -> String {
colored ? "\("Generating".s.Bold) code coverage data..." : "Generating code coverage data..."
}
Expand Down
7 changes: 7 additions & 0 deletions Tests/XcbeautifyLibTests/ParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,11 @@ final class ParserTests: XCTestCase {
XCTAssertEqual(captureGroup.filename, #"BirdFood+DataGeneration.swift"#)
XCTAssertEqual(captureGroup.target, "BackyardBirdsData")
}

func testMatchExplicitDependency() throws {
let input = #" ➜ Explicit dependency on target 'BackyardBirdsData_BackyardBirdsData' in project 'Backyard Birds Data'"#
let captureGroup = try XCTUnwrap(parser.parse(line: input) as? ExplicitDependencyCaptureGroup)
XCTAssertEqual(captureGroup.target, "BackyardBirdsData_BackyardBirdsData")
XCTAssertEqual(captureGroup.project, "Backyard Birds Data")
}
}
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, 277)
XCTAssertEqual(uncapturedOutput, 255)
#else
XCTAssertEqual(uncapturedOutput, 293)
XCTAssertEqual(uncapturedOutput, 271)
#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, 9223)
XCTAssertEqual(uncapturedOutput, 8519)
#else
XCTAssertEqual(uncapturedOutput, 9791)
XCTAssertEqual(uncapturedOutput, 9087)
#endif
}
}