-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82561f9
commit 18b74a3
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// UniqueCaptureGroupTests.swift | ||
// xcbeautify | ||
// | ||
// Created by Charles Pisciotta on 1/22/25. | ||
// | ||
|
||
import XCTest | ||
@testable import XcbeautifyLib | ||
|
||
final class UniqueCaptureGroupTests: XCTestCase { | ||
|
||
let captureGroupTypes = Parser().__for_test__captureGroupTypes() | ||
|
||
func testUniqueCaptureGroups() throws { | ||
let url = try XCTUnwrap(Bundle.module.url(forResource: "clean_build_xcode_15_1", withExtension: "txt")) | ||
|
||
var buildLog: [String] = try String(contentsOf: url) | ||
.components(separatedBy: .newlines) | ||
|
||
while !buildLog.isEmpty { | ||
let line = buildLog.removeFirst() | ||
|
||
let capturedTypes = captureGroupTypes.filter { type in | ||
guard let groups = type.regex.captureGroups(for: line) else { return false } | ||
XCTAssertNotNil(type.init(groups: groups)) | ||
return true | ||
} | ||
|
||
XCTAssertLessThanOrEqual( | ||
capturedTypes.count, | ||
1, | ||
""" | ||
Failed to uniquely parse xcodebuild output. | ||
Line: \(line) | ||
Captured Types: \(ListFormatter.localizedString(byJoining: capturedTypes.map(String.init(describing:)))) | ||
""" | ||
) | ||
} | ||
} | ||
|
||
} |