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

Make capture groups work for swift testing in combination with XCTestcases in same target #326

Merged
merged 5 commits into from
Oct 21, 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
4 changes: 2 additions & 2 deletions Sources/XcbeautifyLib/CaptureGroups.swift
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ struct ParallelTestCasePassedCaptureGroup: CaptureGroup {
/// $2 = test case
/// $3 = installed app file and ID (e.g. "MyApp.app (12345)"), process (e.g. "xctest (12345)"), or device (e.g. "iPhone X")
/// $4 = time
static let regex = Regex(pattern: #"^Test\s+case\s+'(.*)\.(.*)\(\)'\s+passed\s+on\s+'(.*)'\s+\((\d*\.(.*){3})\s+seconds\)"#)
static let regex = Regex(pattern: #"^Test\s+case\s+'(.*)[\.\/](.*)\(\)'\s+passed\s+on\s+'(.*)'\s+\((\d*\.(.*){3})\s+seconds\)"#)

let suite: String
let testCase: String
Expand Down Expand Up @@ -917,7 +917,7 @@ struct ParallelTestCaseFailedCaptureGroup: CaptureGroup {
/// $2 = test case
/// $3 = installed app file and ID (e.g. "MyApp.app (12345)"), process (e.g. "xctest (12345)"), or device (e.g. "iPhone X")
/// $4 = time
static let regex = Regex(pattern: #"^Test\s+case\s+'(.*)\.(.*)\(\)'\s+failed\s+on\s+'(.*)'\s+\((\d*\.(.*){3})\s+seconds\)"#)
static let regex = Regex(pattern: #"^Test\s+case\s+'(.*)[\./](.*)\(\)'\s+failed\s+on\s+'(.*)'\s+\((\d*\.(.*){3})\s+seconds\)"#)

let suite: String
let testCase: String
Expand Down
16 changes: 16 additions & 0 deletions Tests/XcbeautifyLibTests/ParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,20 @@ final class ParserTests: XCTestCase {
let captureGroup = try XCTUnwrap(parser.parse(line: input) as? SwiftDriverCompilationRequirementsCaptureGroup)
XCTAssertEqual(captureGroup.target, #"Backyard\ Birds"#)
}

func testParseSwiftTestingParallelTestOutputPassed() throws {
let resultSuccess = try XCTUnwrap(parser.parse(line: "Test case 'SomeStructThatsNotASuite/someFunctionName()' passed on 'Clone 1 of iPhone 16 Pro - xctest (38347)' (13.060 seconds)") as? ParallelTestCasePassedCaptureGroup)
XCTAssertEqual(resultSuccess.device, "Clone 1 of iPhone 16 Pro - xctest (38347)")
XCTAssertEqual(resultSuccess.suite, "SomeStructThatsNotASuite")
XCTAssertEqual(resultSuccess.time, "13.060")
XCTAssertEqual(resultSuccess.testCase, "someFunctionName")
}

func testParseSwiftTestingParallelTestOutputFailed() throws {
let resultFailed = try XCTUnwrap(parser.parse(line: "Test case 'SubFolderTestDemoTests/exampleFalse()' failed on 'My Mac - TestDemo (29692)' (0.001 seconds)") as? ParallelTestCaseFailedCaptureGroup)
XCTAssertEqual(resultFailed.device, "My Mac - TestDemo (29692)")
XCTAssertEqual(resultFailed.suite, "SubFolderTestDemoTests")
XCTAssertEqual(resultFailed.time, "0.001")
XCTAssertEqual(resultFailed.testCase, "exampleFalse")
}
}