Skip to content

Commit

Permalink
Delete Duplicate TestSuiteStartCaptureGroup
Browse files Browse the repository at this point in the history
Consolidate with TestSuiteStartedCaptureGroup.
  • Loading branch information
cpisciotta committed Feb 10, 2025
1 parent 577fc8d commit a15a64c
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 51 deletions.
32 changes: 6 additions & 26 deletions Sources/XcbeautifyLib/CaptureGroups.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1318,41 +1318,21 @@ struct TestSuiteStartedCaptureGroup: CaptureGroup {
static let outputType: OutputType = .test

/// Regular expression captured groups:
/// $1 = suite
/// $1 = suite name
/// $2 = time
#if os(Linux)
static let regex = XCRegex(pattern: #"^\s*Test Suite '(.*)' started at(.*)"#)
#else
static let regex = XCRegex(pattern: #"^\s*Test Suite '(?:.*\/)?(.*[ox]ctest.*)' started at(.*)"#)
#endif
static let regex = XCRegex(pattern: #"^\s*Test Suite '(.*)' started at (.*)$"#)

let suite: String
let suiteName: String
let time: String

init?(groups: [String]) {
assert(groups.count >= 2)
guard let suite = groups[safe: 0], let time = groups[safe: 1] else { return nil }
self.suite = suite
assert(groups.count == 2)
guard let suiteName = groups[safe: 0], let time = groups[safe: 1] else { return nil }
self.suiteName = suiteName
self.time = time
}
}

struct TestSuiteStartCaptureGroup: CaptureGroup {
static let outputType: OutputType = .test

/// Regular expression captured groups:
/// $1 = test suite name
static let regex = XCRegex(pattern: #"^\s*Test Suite '(.*)' started at"#)

let testSuiteName: String

init?(groups: [String]) {
assert(groups.count >= 1)
guard let testSuiteName = groups[safe: 0] else { return nil }
self.testSuiteName = testSuiteName
}
}

struct TestSuiteAllTestsPassedCaptureGroup: CaptureGroup {
static let outputType: OutputType = .result
static let regex = XCRegex(pattern: #"^\s*(Test Suite 'All tests' passed at.*)"#)
Expand Down
2 changes: 0 additions & 2 deletions Sources/XcbeautifyLib/Formatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ package struct Formatter {
return renderer.formatTestSuiteAllTestsFailed(group: group)
case let group as TestSuiteAllTestsPassedCaptureGroup:
return renderer.formatTestSuiteAllTestsPassed(group: group)
case let group as TestSuiteStartCaptureGroup:
return renderer.formatTestSuiteStart(group: group)
case let group as TestSuiteStartedCaptureGroup:
return renderer.formatTestSuiteStarted(group: group)
case let group as TIFFutilCaptureGroup:
Expand Down
6 changes: 3 additions & 3 deletions Sources/XcbeautifyLib/JunitReporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ package final class JunitReporter {
} else if let groups = TestCaseSkippedCaptureGroup.regex.captureGroups(for: line) {
guard let testCase = generateSkippedTest(groups: groups) else { return }
components.append(.skippedTest(testCase))
} else if let groups = TestSuiteStartCaptureGroup.regex.captureGroups(for: line) {
} else if let groups = TestSuiteStartedCaptureGroup.regex.captureGroups(for: line) {
guard let testStart = generateSuiteStart(groups: groups) else { return }
components.append(.testSuiteStart(testStart))
} else if let groups = ParallelTestCaseFailedCaptureGroup.regex.captureGroups(for: line) {
Expand Down Expand Up @@ -91,8 +91,8 @@ package final class JunitReporter {
}

private func generateSuiteStart(groups: [String]) -> String? {
guard let group = TestSuiteStartCaptureGroup(groups: groups) else { return nil }
return group.testSuiteName
guard let group = TestSuiteStartedCaptureGroup(groups: groups) else { return nil }
return group.suiteName
}

package func generateReport() throws -> Data {
Expand Down
1 change: 0 additions & 1 deletion Sources/XcbeautifyLib/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ package final class Parser {
ProcessInfoPlistCaptureGroup.self,
TestsRunCompletionCaptureGroup.self,
TestSuiteStartedCaptureGroup.self,
TestSuiteStartCaptureGroup.self,
TIFFutilCaptureGroup.self,
TouchCaptureGroup.self,
WriteFileCaptureGroup.self,
Expand Down
8 changes: 1 addition & 7 deletions Sources/XcbeautifyLib/Renderers/OutputRendering.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ protocol OutputRendering {
func formatTestsRunCompletion(group: TestsRunCompletionCaptureGroup) -> String
func formatTestSuiteAllTestsFailed(group: TestSuiteAllTestsFailedCaptureGroup) -> String
func formatTestSuiteAllTestsPassed(group: TestSuiteAllTestsPassedCaptureGroup) -> String
func formatTestSuiteStart(group: TestSuiteStartCaptureGroup) -> String
func formatTestSuiteStarted(group: TestSuiteStartedCaptureGroup) -> String
func formatTIFFUtil(group: TIFFutilCaptureGroup) -> String?
func formatTouch(group: TouchCaptureGroup) -> String
Expand Down Expand Up @@ -387,13 +386,8 @@ extension OutputRendering {
group.wholeResult
}

func formatTestSuiteStart(group: TestSuiteStartCaptureGroup) -> String {
let testSuite = group.testSuiteName
return colored ? testSuite.s.Bold : testSuite
}

func formatTestSuiteStarted(group: TestSuiteStartedCaptureGroup) -> String {
let testSuite = group.suite
let testSuite = group.testSuiteName
let heading = "Test Suite \(testSuite) started"
return colored ? heading.s.Bold.f.Cyan : heading
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,11 @@ final class AzureDevOpsPipelinesRendererTests: XCTestCase {

func testTestCaseStarted() { }

func testTestSuiteStart() { }

func testTestSuiteStarted() { }
func testTestSuiteStarted() {
let input = "Test Suite 'swift-testingPackageTests.xctest' started at 2024-10-09 16:48:58.588."
let formatted = logFormatted(input)
XCTAssertEqual(formatted, input)
}

#if os(macOS)
func testTestSuiteAllTestsPassed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,11 @@ final class GitHubActionsRendererTests: XCTestCase {

func testTestCaseStarted() { }

func testTestSuiteStart() { }

func testTestSuiteStarted() { }
func testTestSuiteStarted() {
let input = "Test Suite 'swift-testingPackageTests.xctest' started at 2024-10-09 16:48:58.588."
let formatted = logFormatted(input)
XCTAssertEqual(formatted, input)
}

#if os(macOS)
func testTestSuiteAllTestsPassed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,11 @@ final class TeamCityRendererTests: XCTestCase {

func testTestCaseStarted() { }

func testTestSuiteStart() { }

func testTestSuiteStarted() { }
func testTestSuiteStarted() {
let input = "Test Suite 'swift-testingPackageTests.xctest' started at 2024-10-09 16:48:58.588."
let formatted = noColoredFormatted(input)
XCTAssertEqual(formatted, input)
}

#if os(macOS)
func testTestSuiteAllTestsPassed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,11 @@ final class TerminalRendererTests: XCTestCase {

func testTestCaseStarted() { }

func testTestSuiteStart() { }

func testTestSuiteStarted() { }
func testTestSuiteStarted() {
let input = "Test Suite 'swift-testingPackageTests.xctest' started at 2024-10-09 16:48:58.588."
let formatted = noColoredFormatted(input)
XCTAssertEqual(formatted, input)
}

#if os(macOS)
func testTestSuiteAllTestsPassed() {
Expand Down

0 comments on commit a15a64c

Please sign in to comment.