Skip to content

Commit

Permalink
Fix Parallel Test Regexes (#326)
Browse files Browse the repository at this point in the history
Support XCTestCase and Swift Testing regexes.

---------

Co-authored-by: Charles Pisciotta <cpisciottadeveloping@gmail.com>
  • Loading branch information
bobvoorneveld and cpisciotta authored Oct 21, 2024
1 parent ebb37ba commit e47d52c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
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")
}
}

0 comments on commit e47d52c

Please sign in to comment.