Skip to content

Commit

Permalink
Add ScanDependencies Capture Group (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpisciotta authored Jan 20, 2025
1 parent d7b97b3 commit 8a08dfe
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Sources/XcbeautifyLib/CaptureGroups.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,22 @@ struct ProcessInfoPlistCaptureGroup: CaptureGroup {
}
}

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

static let regex = XCRegex(pattern: #"ScanDependencies .* normal (?:arm64|x86_64) .* \(in target '(.*)' from 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 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 @@ -172,6 +172,8 @@ package struct Formatter {
return renderer.formatError(group: group)
case let group as RestartingTestCaptureGroup:
return renderer.formatRestartingTest(group: group)
case let group as ScanDependenciesCaptureGroup:
return renderer.formatScanDependencies(group: group)
case let group as ShellCommandCaptureGroup:
return renderer.formatShellCommand(group: group)
case let group as SymbolReferencedFromCaptureGroup:
Expand Down
1 change: 1 addition & 0 deletions Sources/XcbeautifyLib/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ package final class Parser {
ModuleIncludesErrorCaptureGroup.self,
ParallelTestingFailedCaptureGroup.self,
ParallelTestCaseFailedCaptureGroup.self,
ScanDependenciesCaptureGroup.self,
ShellCommandCaptureGroup.self,
UndefinedSymbolLocationCaptureGroup.self,
PackageFetchingCaptureGroup.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 @@ -63,6 +63,7 @@ protocol OutputRendering {
func formatProcessPch(group: ProcessPchCaptureGroup) -> String
func formatProcessPchCommand(group: ProcessPchCommandCaptureGroup) -> String
func formatRestartingTest(group: RestartingTestCaptureGroup) -> String
func formatScanDependencies(group: ScanDependenciesCaptureGroup) -> String?
func formatShellCommand(group: ShellCommandCaptureGroup) -> String?
func formatSymbolReferencedFrom(group: SymbolReferencedFromCaptureGroup) -> String
func formatTargetCommand(command: String, group: any TargetCaptureGroup) -> String
Expand Down Expand Up @@ -314,6 +315,10 @@ extension OutputRendering {
return colored ? "\("Preprocessing".s.Bold) \(filePath)" : "Preprocessing \(filePath)"
}

func formatScanDependencies(group: ScanDependenciesCaptureGroup) -> String? {
nil
}

func formatShellCommand(group: ShellCommandCaptureGroup) -> String? {
nil
}
Expand Down
8 changes: 8 additions & 0 deletions Tests/XcbeautifyLibTests/CaptureGroupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ final class CaptureGroupTests: XCTestCase {
XCTAssertEqual(groups[0], "/Users/Some/Random-Path/_To/A/Build/Intermediates.noindex/ExplicitPrecompileModules/file-ABC123.scan")
}

func testScanDependencies() throws {
let input = #"ScanDependencies /Users/Some/Random-Path/_To/A/Build/Intermediates.noindex/Some/Other.build/x86_64/file-ABC123.o /Users/Some/Other-Random-Path/_To/A/Build/Intermediates.noindex/Some/Other.build/x86_64/file-DEF456.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'SomeTarget' from project 'SomeProject')"#
let groups = try XCTUnwrap(ScanDependenciesCaptureGroup.regex.captureGroups(for: input))
XCTAssertEqual(groups.count, 2)
XCTAssertEqual(groups[0], "SomeTarget")
XCTAssertEqual(groups[1], "SomeProject")
}

func testUnindentedShellCommand() throws {
let input = #"/Applications/Xcode-16.0.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target arm64-apple-macos14.0 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -O0 -L/Backyard-Birds/Build/Intermediates.noindex/EagerLinkingTBDs/Debug -L/Backyard-Birds/Build/Products/Debug -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F/Backyard-Birds/Build/Intermediates.noindex/EagerLinkingTBDs/Debug -F/Backyard-Birds/Build/Products/Debug/PackageFrameworks -F/Backyard-Birds/Build/Products/Debug -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -filelist /Backyard-Birds/Build/Intermediates.noindex/BackyardBirdsData.build/Debug/BackyardBirdsData\ product.build/Objects-normal/arm64/BackyardBirdsData.LinkFileList -install_name @rpath/BackyardBirdsData.framework/Versions/A/BackyardBirdsData -Xlinker -rpath -Xlinker /Backyard-Birds/Build/Products/Debug/PackageFrameworks -Xlinker -object_path_lto -Xlinker /Backyard-Birds/Build/Intermediates.noindex/BackyardBirdsData.build/Debug/BackyardBirdsData\ product.build/Objects-normal/arm64/BackyardBirdsData_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -L/usr/lib/swift -Wl,-no_warn_duplicate_libraries -Xlinker -dependency_info -Xlinker /Backyard-Birds/Build/Intermediates.noindex/BackyardBirdsData.build/Debug/BackyardBirdsData\ product.build/Objects-normal/arm64/BackyardBirdsData_dependency_info.dat -o /Backyard-Birds/Build/Intermediates.noindex/BackyardBirdsData.build/Debug/BackyardBirdsData\ product.build/Objects-normal/arm64/Binary/BackyardBirdsData -Xlinker -add_ast_path -Xlinker /Backyard-Birds/Build/Intermediates.noindex/BackyardBirdsData.build/Debug/BackyardBirdsData.build/Objects-normal/arm64/BackyardBirdsData.swiftmodule"#
let groups = try XCTUnwrap(NonPCHClangCommandCaptureGroup.regex.captureGroups(for: input))
Expand Down
7 changes: 7 additions & 0 deletions Tests/XcbeautifyLibTests/ParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ final class ParserTests: XCTestCase {
XCTAssertEqual(captureGroup.numberOfArguments, 2)
}

func testMatchScanDependencies() throws {
let input = #"ScanDependencies /Users/Some/Random-Path/_To/A/Build/Intermediates.noindex/Some/Other.build/x86_64/file-ABC123.o /Users/Some/Other-Random-Path/_To/A/Build/Intermediates.noindex/Some/Other.build/x86_64/file-DEF456.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'SomeTarget' from project 'SomeProject')"#
let captureGroup = try XCTUnwrap(parser.parse(line: input) as? ScanDependenciesCaptureGroup)
XCTAssertEqual(captureGroup.target, "SomeTarget")
XCTAssertEqual(captureGroup.project, "SomeProject")
}

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,11 @@ final class AzureDevOpsPipelinesRendererTests: XCTestCase {
XCTAssertEqual(formatted, "##vso[task.logissue type=error] Restarting after unexpected exit, crash, or test timeout in HomePresenterTest.testIsCellPresented(); summary will include totals from previous launches.")
}

func testScanDependencies() {
let formatted = logFormatted(#"ScanDependencies /Users/Some/Random-Path/_To/A/Build/Intermediates.noindex/Some/Other.build/x86_64/file-ABC123.o /Users/Some/Other-Random-Path/_To/A/Build/Intermediates.noindex/Some/Other.build/x86_64/file-DEF456.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'SomeTarget' from project 'SomeProject')"#)
XCTAssertNil(formatted)
}

func testShellCommand() {
let formatted = logFormatted(" cd /foo/bar/baz")
XCTAssertNil(formatted)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,11 @@ final class GitHubActionsRendererTests: XCTestCase {
XCTAssertEqual(formatted, "::error :: Restarting after unexpected exit, crash, or test timeout in HomePresenterTest.testIsCellPresented(); summary will include totals from previous launches.")
}

func testScanDependencies() {
let formatted = logFormatted(#"ScanDependencies /Users/Some/Random-Path/_To/A/Build/Intermediates.noindex/Some/Other.build/x86_64/file-ABC123.o /Users/Some/Other-Random-Path/_To/A/Build/Intermediates.noindex/Some/Other.build/x86_64/file-DEF456.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'SomeTarget' from project 'SomeProject')"#)
XCTAssertNil(formatted)
}

func testShellCommand() {
let formatted = logFormatted(" cd /foo/bar/baz")
XCTAssertNil(formatted)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@ final class TeamCityRendererTests: XCTestCase {
XCTAssertEqual(formatted, " ✖ Restarting after unexpected exit, crash, or test timeout in HomePresenterTest.testIsCellPresented(); summary will include totals from previous launches.")
}

func testScanDependencies() {
let formatted = noColoredFormatted(#"ScanDependencies /Users/Some/Random-Path/_To/A/Build/Intermediates.noindex/Some/Other.build/x86_64/file-ABC123.o /Users/Some/Other-Random-Path/_To/A/Build/Intermediates.noindex/Some/Other.build/x86_64/file-DEF456.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'SomeTarget' from project 'SomeProject')"#)
XCTAssertNil(formatted)
}

func testShellCommand() {
let formatted = noColoredFormatted(" cd /foo/bar/baz")
XCTAssertNil(formatted)
Expand Down

0 comments on commit 8a08dfe

Please sign in to comment.