Skip to content

Commit

Permalink
Add RegisterExecutionPolicyExceptionCaptureGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
cpisciotta committed Jan 20, 2025
1 parent cec33f4 commit 2cc9e59
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 4 deletions.
20 changes: 20 additions & 0 deletions Sources/XcbeautifyLib/CaptureGroups.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,26 @@ struct ProcessInfoPlistCaptureGroup: CaptureGroup {
}
}

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

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

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

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

struct ScanDependenciesCaptureGroup: 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 @@ -172,6 +172,8 @@ package struct Formatter {
return renderer.formatProcessPchCommand(group: group)
case let group as ProvisioningProfileRequiredCaptureGroup:
return renderer.formatError(group: group)
case let group as RegisterExecutionPolicyExceptionCaptureGroup:
return renderer.formatRegisterExecutionPolicyException(group: group)
case let group as RestartingTestCaptureGroup:
return renderer.formatRestartingTest(group: group)
case let group as ScanDependenciesCaptureGroup:
Expand Down
1 change: 1 addition & 0 deletions Sources/XcbeautifyLib/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ package final class Parser {
PackageGraphResolvingStartCaptureGroup.self,
PackageGraphResolvingEndedCaptureGroup.self,
PackageGraphResolvedItemCaptureGroup.self,
RegisterExecutionPolicyExceptionCaptureGroup.self,
DuplicateLocalizedStringKeyCaptureGroup.self,
SigningCaptureGroup.self,
SwiftDriverJobDiscoveryEmittingModuleCaptureGroup.self,
Expand Down
7 changes: 7 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 formatProcessInfoPlist(group: ProcessInfoPlistCaptureGroup) -> String
func formatProcessPch(group: ProcessPchCaptureGroup) -> String
func formatProcessPchCommand(group: ProcessPchCommandCaptureGroup) -> String
func formatRegisterExecutionPolicyException(group: RegisterExecutionPolicyExceptionCaptureGroup) -> String
func formatRestartingTest(group: RestartingTestCaptureGroup) -> String
func formatScanDependencies(group: ScanDependenciesCaptureGroup) -> String?
func formatShellCommand(group: ShellCommandCaptureGroup) -> String?
Expand Down Expand Up @@ -322,6 +323,12 @@ extension OutputRendering {
return colored ? "\("Preprocessing".s.Bold) \(filePath)" : "Preprocessing \(filePath)"
}

func formatRegisterExecutionPolicyException(group: RegisterExecutionPolicyExceptionCaptureGroup) -> String {
let target = group.target
let filename = group.filename
return colored ? "[\(target.f.Cyan)] \("RegisterExecutionPolicyException".s.Bold) \(filename)" : "[\(target)] RegisterExecutionPolicyException \(filename)"
}

func formatScanDependencies(group: ScanDependenciesCaptureGroup) -> String? {
nil
}
Expand Down
10 changes: 10 additions & 0 deletions Tests/XcbeautifyLibTests/CaptureGroupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ final class CaptureGroupTests: XCTestCase {
XCTAssertEqual(groups[0], "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang")
}

func testRegisterExecutionPolicyException() throws {
let input = #"RegisterExecutionPolicyException /path/to/output.o (in target 'Target' from project 'Project')"#
let groups = try XCTUnwrap(RegisterExecutionPolicyExceptionCaptureGroup.regex.captureGroups(for: input))
XCTAssertEqual(groups.count, 4)
XCTAssertEqual(groups[0], "/path/to/output.o")
XCTAssertEqual(groups[1], "output.o")
XCTAssertEqual(groups[2], "Target")
XCTAssertEqual(groups[3], "Project")
}

func testSwiftEmitModule() throws {
let input = #"SwiftEmitModule normal i386 Emitting\ module\ for\ CasePaths (in target 'CasePathsTarget' from project 'swift-case-paths')"#
let groups = try XCTUnwrap(SwiftEmitModuleCaptureGroup.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 @@ -267,6 +267,14 @@ final class ParserTests: XCTestCase {
XCTAssertEqual(input.path, "/Users/Some/Random-Path/_To/A/Build/Intermediates.noindex/ExplicitPrecompileModules/file-ABC123.scan")
}

func testRegisterExecutionPolicyException() throws {
let captureGroup = try XCTUnwrap(parser.parse(line: "RegisterExecutionPolicyException /path/to/output.o (in target 'Target' from project 'Project')") as? RegisterExecutionPolicyExceptionCaptureGroup)
XCTAssertEqual(captureGroup.filePath, "/path/to/output.o")
XCTAssertEqual(captureGroup.filename, "output.o")
XCTAssertEqual(captureGroup.target, "Target")
XCTAssertEqual(captureGroup.project, "Project")
}

func testSwiftEmitModule() throws {
let captureGroup = try XCTUnwrap(parser.parse(line: #"SwiftEmitModule normal i386 Emitting\ module\ for\ CasePaths (in target 'CasePathsTarget' from project 'swift-case-paths')"#) as? SwiftEmitModuleCaptureGroup)
XCTAssertEqual(captureGroup.arch, "i386")
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, 183)
XCTAssertEqual(uncapturedOutput, 172)
#else
XCTAssertEqual(uncapturedOutput, 199)
XCTAssertEqual(uncapturedOutput, 188)
#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, 6080)
XCTAssertEqual(uncapturedOutput, 5700)
#else
XCTAssertEqual(uncapturedOutput, 6648)
XCTAssertEqual(uncapturedOutput, 6268)
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,11 @@ final class AzureDevOpsPipelinesRendererTests: XCTestCase {
XCTAssertEqual(formatted, #"##vso[task.logissue type=warning]Key "duplicate" used with multiple values. Value "First" kept. Value "Second" ignored."#)
}

func testRegisterExecutionPolicyException() {
let formatted = logFormatted(#"RegisterExecutionPolicyException /path/to/output.o (in target 'Target' from project 'Project')"#)
XCTAssertEqual(formatted, "[Target] RegisterExecutionPolicyException output.o")
}

func testTestingStarted() {
let formatted = logFormatted(#"Testing started"#)
XCTAssertEqual(formatted, #"Testing started"#)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,11 @@ final class GitHubActionsRendererTests: XCTestCase {
XCTAssertEqual(formatted, #"::warning ::Key "duplicate" used with multiple values. Value "First" kept. Value "Second" ignored."#)
}

func testRegisterExecutionPolicyException() {
let formatted = logFormatted(#"RegisterExecutionPolicyException /path/to/output.o (in target 'Target' from project 'Project')"#)
XCTAssertEqual(formatted, "[Target] RegisterExecutionPolicyException output.o")
}

func testTestingStarted() {
let formatted = logFormatted(#"Testing started"#)
XCTAssertEqual(formatted, #"Testing started"#)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,11 @@ final class TeamCityRendererTests: XCTestCase {
XCTAssertEqual(noColoredFormatted(input), output)
}

func testRegisterExecutionPolicyException() {
let formatted = noColoredFormatted(#"RegisterExecutionPolicyException /path/to/output.o (in target 'Target' from project 'Project')"#)
XCTAssertEqual(formatted, "[Target] RegisterExecutionPolicyException output.o")
}

func testRestartingTests() {
let formatted = noColoredFormatted("Restarting after unexpected exit, crash, or test timeout in HomePresenterTest.testIsCellPresented(); summary will include totals from previous launches.")
XCTAssertEqual(formatted, " ✖ Restarting after unexpected exit, crash, or test timeout in HomePresenterTest.testIsCellPresented(); summary will include totals from previous launches.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,11 @@ final class TerminalRendererTests: XCTestCase {
XCTAssertEqual(formatted, #"[!] Key "duplicate" used with multiple values. Value "First" kept. Value "Second" ignored."#)
}

func testRegisterExecutionPolicyException() {
let formatted = noColoredFormatted(#"RegisterExecutionPolicyException /path/to/output.o (in target 'Target' from project 'Project')"#)
XCTAssertEqual(formatted, "[Target] RegisterExecutionPolicyException output.o")
}

func testTestingStarted() {
let formatted = noColoredFormatted(#"Testing started"#)
XCTAssertEqual(formatted, #"Testing started"#)
Expand Down

0 comments on commit 2cc9e59

Please sign in to comment.