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 SymLinkCaptureGroup #387

Merged
merged 1 commit into from
Feb 22, 2025
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
18 changes: 18 additions & 0 deletions Sources/XcbeautifyLib/CaptureGroups.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,24 @@ struct ScanDependenciesCaptureGroup: CaptureGroup {
}
}

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

static let regex = XCRegex(pattern: #"^SymLink (.+) \(in target '(.*)' from project '(.*)'\)$"#)

let filePath: String
let target: String
let project: String

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

struct TestsRunCompletionCaptureGroup: CaptureGroup {
static let outputType: OutputType = .test

Expand Down
2 changes: 2 additions & 0 deletions Sources/XcbeautifyLib/Formatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ package struct Formatter {
return renderer.formatSigning(group: group)
case let group as SymbolReferencedFromCaptureGroup:
return renderer.formatSymbolReferencedFrom(group: group)
case let group as SymLinkCaptureGroup:
return renderer.formatSymLink(group: group)
case let group as TestCaseMeasuredCaptureGroup:
return renderer.formatTestCaseMeasured(group: group)
case let group as TestCasePassedCaptureGroup:
Expand Down
1 change: 1 addition & 0 deletions Sources/XcbeautifyLib/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ package final class Parser {
SigningCaptureGroup.self,
SwiftDriverJobDiscoveryEmittingModuleCaptureGroup.self,
SwiftDriverJobDiscoveryCompilingCaptureGroup.self,
SymLinkCaptureGroup.self,
ExecutedWithoutSkippedCaptureGroup.self,
ExecutedWithSkippedCaptureGroup.self,
TestSuiteAllTestsPassedCaptureGroup.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 @@ -73,6 +73,7 @@ protocol OutputRendering {
func formatScanDependencies(group: ScanDependenciesCaptureGroup) -> String?
func formatShellCommand(group: ShellCommandCaptureGroup) -> String?
func formatSigning(group: SigningCaptureGroup) -> String
func formatSymLink(group: SymLinkCaptureGroup) -> String?
func formatSymbolReferencedFrom(group: SymbolReferencedFromCaptureGroup) -> String
func formatTargetCommand(command: String, group: any TargetCaptureGroup) -> String
func formatTestCaseMeasured(group: TestCaseMeasuredCaptureGroup) -> String
Expand Down Expand Up @@ -538,6 +539,10 @@ extension OutputRendering {
return colored ? Symbol.error + " " + errorMessage.f.Red : Symbol.asciiError + " " + errorMessage
}

func formatSymLink(group: SymLinkCaptureGroup) -> String? {
nil
}

func formatSymbolReferencedFrom(group: SymbolReferencedFromCaptureGroup) -> String {
colored ? Symbol.error + " " + group.wholeError.f.Red : Symbol.asciiError + " " + group.wholeError
}
Expand Down
9 changes: 9 additions & 0 deletions Tests/XcbeautifyLibTests/CaptureGroupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ final class CaptureGroupTests: XCTestCase {
XCTAssertNotNil(SwiftDriverJobDiscoveryEmittingModuleCaptureGroup.regex.captureGroups(for: input))
}

func testMatchSymLink() throws {
let input = "SymLink /Backyard-Birds/Build/Products/Debug/PackageFrameworks/LayeredArtworkLibrary.framework/Resources Versions/Current/Resources (in target 'Some Target_Value' from project 'LayeredArtworkLibrary')"
let groups = try XCTUnwrap(SymLinkCaptureGroup.regex.captureGroups(for: input))
XCTAssertEqual(groups.count, 3)
XCTAssertEqual(groups[0], "/Backyard-Birds/Build/Products/Debug/PackageFrameworks/LayeredArtworkLibrary.framework/Resources Versions/Current/Resources")
XCTAssertEqual(groups[1], "Some Target_Value")
XCTAssertEqual(groups[2], "LayeredArtworkLibrary")
}

func testMkDirCaptureGroup() throws {
let input = "MkDir /Backyard-Birds/Build/Products/Debug/Widgets.appex/Contents (in target \'Widgets\' from project \'Backyard Birds\')"
XCTAssertNotNil(MkDirCaptureGroup.regex.captureGroups(for: input))
Expand Down
8 changes: 8 additions & 0 deletions Tests/XcbeautifyLibTests/ParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ final class ParserTests: XCTestCase {
XCTAssertEqual(captureGroup.project, "LayeredArtworkLibraryProject")
}

func testMatchSymLink() throws {
let input = "SymLink /Backyard-Birds/Build/Products/Debug/PackageFrameworks/LayeredArtworkLibrary.framework/Versions/Current A (in target 'LayeredArtworkLibrary_Target' from project 'LayeredArtworkLibrary_Project')"
let captureGroup = try XCTUnwrap(parser.parse(line: input) as? SymLinkCaptureGroup)
XCTAssertEqual(captureGroup.filePath, "/Backyard-Birds/Build/Products/Debug/PackageFrameworks/LayeredArtworkLibrary.framework/Versions/Current A")
XCTAssertEqual(captureGroup.target, "LayeredArtworkLibrary_Target")
XCTAssertEqual(captureGroup.project, "LayeredArtworkLibrary_Project")
}

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)
Expand Down
8 changes: 4 additions & 4 deletions Tests/XcbeautifyLibTests/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, 58)
XCTAssertEqual(uncapturedOutput, 49)
#else
XCTAssertEqual(uncapturedOutput, 74)
XCTAssertEqual(uncapturedOutput, 65)
#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, 1924)
XCTAssertEqual(uncapturedOutput, 1636)
#else
XCTAssertEqual(uncapturedOutput, 2492)
XCTAssertEqual(uncapturedOutput, 2204)
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,11 @@ final class AzureDevOpsPipelinesRendererTests: XCTestCase {
XCTAssertNil(formatted)
}

func testSymLink() {
let formatted = logFormatted("SymLink /Backyard-Birds/Build/Products/Debug/PackageFrameworks/BackyardBirdsData.framework/BackyardBirdsData Versions/Current/BackyardBirdsData (in target 'BackyardBirdsData' from project 'BackyardBirdsData')")
XCTAssertNil(formatted)
}

func testSymbolReferencedFrom() {
let formatted = logFormatted(" \"NetworkBusiness.ImageDownloadManager.saveImage(image: __C.UIImage, needWatermark: Swift.Bool, params: [Swift.String : Any], downloadHandler: (Swift.Bool) -> ()?) -> ()\", referenced from:")
XCTAssertEqual(formatted, "##vso[task.logissue type=error] \"NetworkBusiness.ImageDownloadManager.saveImage(image: __C.UIImage, needWatermark: Swift.Bool, params: [Swift.String : Any], downloadHandler: (Swift.Bool) -> ()?) -> ()\", referenced from:")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,11 @@ final class GitHubActionsRendererTests: XCTestCase {
XCTAssertNil(formatted)
}

func testSymLink() {
let formatted = logFormatted("SymLink /Backyard-Birds/Build/Products/Debug/PackageFrameworks/BackyardBirdsData.framework/Resources Versions/Current/Resources (in target 'BackyardBirdsData' from project 'BackyardBirdsData')")
XCTAssertNil(formatted)
}

func testSymbolReferencedFrom() {
let formatted = logFormatted(" \"NetworkBusiness.ImageDownloadManager.saveImage(image: __C.UIImage, needWatermark: Swift.Bool, params: [Swift.String : Any], downloadHandler: (Swift.Bool) -> ()?) -> ()\", referenced from:")
XCTAssertEqual(formatted, "::error :: \"NetworkBusiness.ImageDownloadManager.saveImage(image: __C.UIImage, needWatermark: Swift.Bool, params: [Swift.String : Any], downloadHandler: (Swift.Bool) -> ()?) -> ()\", referenced from:")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,11 @@ final class TeamCityRendererTests: XCTestCase {
XCTAssertNil(formatted)
}

func testSymLink() {
let formatted = noColoredFormatted("SymLink /Backyard-Birds/Build/Products/Debug/PackageFrameworks/BackyardBirdsData.framework/Versions/Current A (in target 'BackyardBirdsData' from project 'BackyardBirdsData')")
XCTAssertNil(formatted)
}

func testSymbolReferencedFrom() {
let formatted = noColoredFormatted(" \"NetworkBusiness.ImageDownloadManager.saveImage(image: __C.UIImage, needWatermark: Swift.Bool, params: [Swift.String : Any], downloadHandler: (Swift.Bool) -> ()?) -> ()\", referenced from:")
XCTAssertEqual(formatted, "[x] \"NetworkBusiness.ImageDownloadManager.saveImage(image: __C.UIImage, needWatermark: Swift.Bool, params: [Swift.String : Any], downloadHandler: (Swift.Bool) -> ()?) -> ()\", referenced from:")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,11 @@ final class TerminalRendererTests: XCTestCase {
XCTAssertNil(formatted)
}

func testSymLink() {
let formatted = noColoredFormatted("SymLink /Backyard-Birds/Build/Products/Debug/PackageFrameworks/LayeredArtworkLibrary.framework/LayeredArtworkLibrary Versions/Current/LayeredArtworkLibrary (in target 'LayeredArtworkLibrary' from project 'LayeredArtworkLibrary')")
XCTAssertNil(formatted)
}

func testSymbolReferencedFrom() {
let formatted = noColoredFormatted(" \"NetworkBusiness.ImageDownloadManager.saveImage(image: __C.UIImage, needWatermark: Swift.Bool, params: [Swift.String : Any], downloadHandler: (Swift.Bool) -> ()?) -> ()\", referenced from:")
XCTAssertEqual(formatted, "[x] \"NetworkBusiness.ImageDownloadManager.saveImage(image: __C.UIImage, needWatermark: Swift.Bool, params: [Swift.String : Any], downloadHandler: (Swift.Bool) -> ()?) -> ()\", referenced from:")
Expand Down