From 1ffefd4142cd5d281c86188f29d8eb7a4a166d7e Mon Sep 17 00:00:00 2001 From: Miguel Ferrando Date: Wed, 24 Jul 2024 15:53:01 +0200 Subject: [PATCH 1/9] Add xcode back to the Makefile --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 6a934797..53acba10 100644 --- a/Makefile +++ b/Makefile @@ -131,3 +131,7 @@ export_coverage: .PHONY: measure measure: tools/measure + +.PHONY: xcode +xcode: + open Package.swift From 31f958bc276753be17a129fc5ab6d6371abecd7b Mon Sep 17 00:00:00 2001 From: Miguel Ferrando Date: Wed, 24 Jul 2024 16:31:58 +0200 Subject: [PATCH 2/9] Add retry on failure support for JunitReporter --- Sources/XcbeautifyLib/JunitReporter.swift | 16 +++++++ .../JunitReporterTests.swift | 45 +++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/Sources/XcbeautifyLib/JunitReporter.swift b/Sources/XcbeautifyLib/JunitReporter.swift index 9e61a633..744443d5 100644 --- a/Sources/XcbeautifyLib/JunitReporter.swift +++ b/Sources/XcbeautifyLib/JunitReporter.swift @@ -27,6 +27,12 @@ package final class JunitReporter { components.append(.failingTest(testCase)) } else if TestCasePassedCaptureGroup.regex.match(string: line) { guard let testCase = generatePassingTest(line: line) else { return } + // remove previous failing test if retry succeeded + if let previousTestCase = components.last?.testCase, + testCase.classname == previousTestCase.classname, + testCase.name == previousTestCase.name { + components.removeLast() + } components.append(.testCasePassed(testCase)) } else if TestCaseSkippedCaptureGroup.regex.match(string: line) { guard let testCase = generateSkippedTest(line: line) else { return } @@ -158,6 +164,16 @@ private enum JunitComponent { case skippedTest(TestCase) } +private extension JunitComponent { + var testCase: TestCase? { + switch self { + case .testSuiteStart: nil + case .failingTest(let testCase), .testCasePassed(let testCase), .skippedTest(let testCase): + testCase + } + } +} + private struct Testsuites: Encodable, DynamicNodeEncoding { var name: String? var testsuites: [Testsuite] = [] diff --git a/Tests/XcbeautifyLibTests/JunitReporterTests.swift b/Tests/XcbeautifyLibTests/JunitReporterTests.swift index c00725b7..aca8ee53 100644 --- a/Tests/XcbeautifyLibTests/JunitReporterTests.swift +++ b/Tests/XcbeautifyLibTests/JunitReporterTests.swift @@ -409,6 +409,51 @@ class JunitReporterTests: XCTestCase { #endif XCTAssertEqual(xml, expectedXml) } + + private let retryOnFailureTests = """ + Test Suite 'All tests' started at 2021-11-05 01:08:23.237 + Test Suite 'xcbeautifyPackageTests.xctest' started at 2021-11-05 01:08:23.238 + Test Suite 'OutputHandlerTests' started at 2021-11-05 01:08:23.238 + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString]' started (Iteration 1 of 3). + /Users/andres/Git/xcbeautify/Tests/XcbeautifyLibTests/OutputHandlerTests.swift:13: error: -[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString] : XCTAssertEqual failed: ("Optional("Aggregate target Be Aggro of project AggregateExample with configuration Debug")") is not equal to ("Optional("failing Aggregate target Be Aggro of project AggregateExample with configuration Debug")") + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString]' failed (0.208 seconds). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString]' started (Iteration 2 of 3). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString]' passed (0.054 seconds). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintAllOutputTypeByDefault]' started (Iteration 1 of 3). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintAllOutputTypeByDefault]' passed (0.000 seconds). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintOnlyTasksWithError]' started (Iteration 1 of 3). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintOnlyTasksWithError]' passed (0.000 seconds). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintOnlyTasksWithWarningOrError]' started (Iteration 1 of 3). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintOnlyTasksWithWarningOrError]' passed (0.000 seconds). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintTestResultTooIfIsCIAndQuiet]' started (Iteration 1 of 3). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintTestResultTooIfIsCIAndQuiet]' passed (0.000 seconds). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintTestResultTooIfIsCIAndQuieter]' started (Iteration 1 of 3). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintTestResultTooIfIsCIAndQuieter]' passed (0.000 seconds). + Test Suite 'OutputHandlerTests' passed at 2021-11-05 01:08:23.294. + Executed 6 tests, with 0 failures (0 unexpected) in 0.055 (0.056) seconds + """ + + private let expectedRetryOnFailureXml = """ + + + + + + + + + + + """ + + func testJunitReportWithRetries() throws { + let reporter = JunitReporter() + retryOnFailureTests.components(separatedBy: .newlines).forEach { reporter.add(line: $0) } + let data = try reporter.generateReport() + let xml = String(data: data, encoding: .utf8)! + let expectedXml = expectedRetryOnFailureXml + XCTAssertEqual(xml, expectedXml) + } private let parallelTests = """ Test suite 'MobileWebURLRouteTest' started on 'Clone 1 of iPhone 13 mini - xctest (32505)' From 6641dfb4953b50f546a00fb7afa9bbcdeb6bd194 Mon Sep 17 00:00:00 2001 From: Miguel Ferrando Date: Thu, 25 Jul 2024 09:23:16 +0200 Subject: [PATCH 3/9] Apply code format --- Sources/XcbeautifyLib/JunitReporter.swift | 9 +++++---- Tests/XcbeautifyLibTests/JunitReporterTests.swift | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Sources/XcbeautifyLib/JunitReporter.swift b/Sources/XcbeautifyLib/JunitReporter.swift index 744443d5..bae4e93a 100644 --- a/Sources/XcbeautifyLib/JunitReporter.swift +++ b/Sources/XcbeautifyLib/JunitReporter.swift @@ -28,9 +28,10 @@ package final class JunitReporter { } else if TestCasePassedCaptureGroup.regex.match(string: line) { guard let testCase = generatePassingTest(line: line) else { return } // remove previous failing test if retry succeeded - if let previousTestCase = components.last?.testCase, - testCase.classname == previousTestCase.classname, - testCase.name == previousTestCase.name { + if let previousTestCase = components.last?.testCase, + testCase.classname == previousTestCase.classname, + testCase.name == previousTestCase.name + { components.removeLast() } components.append(.testCasePassed(testCase)) @@ -168,7 +169,7 @@ private extension JunitComponent { var testCase: TestCase? { switch self { case .testSuiteStart: nil - case .failingTest(let testCase), .testCasePassed(let testCase), .skippedTest(let testCase): + case let .failingTest(testCase), let .testCasePassed(testCase), let .skippedTest(testCase): testCase } } diff --git a/Tests/XcbeautifyLibTests/JunitReporterTests.swift b/Tests/XcbeautifyLibTests/JunitReporterTests.swift index aca8ee53..ba2aab3d 100644 --- a/Tests/XcbeautifyLibTests/JunitReporterTests.swift +++ b/Tests/XcbeautifyLibTests/JunitReporterTests.swift @@ -409,7 +409,7 @@ class JunitReporterTests: XCTestCase { #endif XCTAssertEqual(xml, expectedXml) } - + private let retryOnFailureTests = """ Test Suite 'All tests' started at 2021-11-05 01:08:23.237 Test Suite 'xcbeautifyPackageTests.xctest' started at 2021-11-05 01:08:23.238 @@ -432,7 +432,7 @@ class JunitReporterTests: XCTestCase { Test Suite 'OutputHandlerTests' passed at 2021-11-05 01:08:23.294. Executed 6 tests, with 0 failures (0 unexpected) in 0.055 (0.056) seconds """ - + private let expectedRetryOnFailureXml = """ @@ -445,7 +445,7 @@ class JunitReporterTests: XCTestCase { """ - + func testJunitReportWithRetries() throws { let reporter = JunitReporter() retryOnFailureTests.components(separatedBy: .newlines).forEach { reporter.add(line: $0) } From 4174b0620d5137b31c3e4e42b04a9594f3c93432 Mon Sep 17 00:00:00 2001 From: Miguel Ferrando Date: Thu, 25 Jul 2024 11:46:27 +0200 Subject: [PATCH 4/9] Fix test on Linux --- .../XcbeautifyLibTests/JunitReporterTests.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Tests/XcbeautifyLibTests/JunitReporterTests.swift b/Tests/XcbeautifyLibTests/JunitReporterTests.swift index ba2aab3d..75d98fbb 100644 --- a/Tests/XcbeautifyLibTests/JunitReporterTests.swift +++ b/Tests/XcbeautifyLibTests/JunitReporterTests.swift @@ -446,12 +446,29 @@ class JunitReporterTests: XCTestCase { """ + private let expectedRetryOnFailureLinuxXml = """ + + + + + + + + + + + """ + func testJunitReportWithRetries() throws { let reporter = JunitReporter() retryOnFailureTests.components(separatedBy: .newlines).forEach { reporter.add(line: $0) } let data = try reporter.generateReport() let xml = String(data: data, encoding: .utf8)! + #if os(Linux) + let expectedXml = expectedRetryOnFailureLinuxXml + #else let expectedXml = expectedRetryOnFailureXml + #endif XCTAssertEqual(xml, expectedXml) } From 49b4559aeef9eaa170aff34f3efb6a08a1181cf8 Mon Sep 17 00:00:00 2001 From: Miguel Ferrando Date: Fri, 26 Jul 2024 12:38:42 +0200 Subject: [PATCH 5/9] Remove all failing tests after success Not only the previous one --- Sources/XcbeautifyLib/JunitReporter.swift | 23 +++++++++++++------ .../JunitReporterTests.swift | 3 +++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Sources/XcbeautifyLib/JunitReporter.swift b/Sources/XcbeautifyLib/JunitReporter.swift index bae4e93a..9a95ad73 100644 --- a/Sources/XcbeautifyLib/JunitReporter.swift +++ b/Sources/XcbeautifyLib/JunitReporter.swift @@ -27,13 +27,7 @@ package final class JunitReporter { components.append(.failingTest(testCase)) } else if TestCasePassedCaptureGroup.regex.match(string: line) { guard let testCase = generatePassingTest(line: line) else { return } - // remove previous failing test if retry succeeded - if let previousTestCase = components.last?.testCase, - testCase.classname == previousTestCase.classname, - testCase.name == previousTestCase.name - { - components.removeLast() - } + components.removePreviousFailingTestsAfterPassed(testCase) components.append(.testCasePassed(testCase)) } else if TestCaseSkippedCaptureGroup.regex.match(string: line) { guard let testCase = generateSkippedTest(line: line) else { return } @@ -175,6 +169,21 @@ private extension JunitComponent { } } +private extension [JunitComponent] { + mutating func removePreviousFailingTestsAfterPassed(_ testCase: TestCase) { + // base case, empty array or last is not the last passed test case + guard let previousTestCase = last?.testCase, + testCase.classname == previousTestCase.classname, + testCase.name == previousTestCase.name + else { + return + } + removeLast() + // keep removing + removePreviousFailingTestsAfterPassed(testCase) + } +} + private struct Testsuites: Encodable, DynamicNodeEncoding { var name: String? var testsuites: [Testsuite] = [] diff --git a/Tests/XcbeautifyLibTests/JunitReporterTests.swift b/Tests/XcbeautifyLibTests/JunitReporterTests.swift index 75d98fbb..f93fbe49 100644 --- a/Tests/XcbeautifyLibTests/JunitReporterTests.swift +++ b/Tests/XcbeautifyLibTests/JunitReporterTests.swift @@ -418,6 +418,9 @@ class JunitReporterTests: XCTestCase { /Users/andres/Git/xcbeautify/Tests/XcbeautifyLibTests/OutputHandlerTests.swift:13: error: -[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString] : XCTAssertEqual failed: ("Optional("Aggregate target Be Aggro of project AggregateExample with configuration Debug")") is not equal to ("Optional("failing Aggregate target Be Aggro of project AggregateExample with configuration Debug")") Test Case '-[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString]' failed (0.208 seconds). Test Case '-[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString]' started (Iteration 2 of 3). + /Users/andres/Git/xcbeautify/Tests/XcbeautifyLibTests/OutputHandlerTests.swift:13: error: -[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString] : XCTAssertEqual failed: ("Optional("Aggregate target Be Aggro of project AggregateExample with configuration Debug")") is not equal to ("Optional("failing Aggregate target Be Aggro of project AggregateExample with configuration Debug")") + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString]' failed (0.208 seconds). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString]' started (Iteration 3 of 3). Test Case '-[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString]' passed (0.054 seconds). Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintAllOutputTypeByDefault]' started (Iteration 1 of 3). Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintAllOutputTypeByDefault]' passed (0.000 seconds). From fe005615c463d0215f15e062c1028995cb7b420a Mon Sep 17 00:00:00 2001 From: Miguel Ferrando Date: Tue, 30 Jul 2024 09:47:32 +0200 Subject: [PATCH 6/9] Filter out same failing tests in report --- Sources/XcbeautifyLib/JunitReporter.swift | 9 ++- .../JunitReporterTests.swift | 73 ++++++++++++++++++- 2 files changed, 78 insertions(+), 4 deletions(-) diff --git a/Sources/XcbeautifyLib/JunitReporter.swift b/Sources/XcbeautifyLib/JunitReporter.swift index 9a95ad73..368e3e95 100644 --- a/Sources/XcbeautifyLib/JunitReporter.swift +++ b/Sources/XcbeautifyLib/JunitReporter.swift @@ -21,13 +21,16 @@ package final class JunitReporter { if FailingTestCaptureGroup.regex.match(string: line) { guard let testCase = generateFailingTest(line: line) else { return } + // reduce failing retrys, if any + components.removePreviousFailingTestsAfter(testCase) components.append(.failingTest(testCase)) } else if RestartingTestCaptureGroup.regex.match(string: line) { guard let testCase = generateRestartingTest(line: line) else { return } components.append(.failingTest(testCase)) } else if TestCasePassedCaptureGroup.regex.match(string: line) { guard let testCase = generatePassingTest(line: line) else { return } - components.removePreviousFailingTestsAfterPassed(testCase) + // filter out failing retrys, if any + components.removePreviousFailingTestsAfter(testCase) components.append(.testCasePassed(testCase)) } else if TestCaseSkippedCaptureGroup.regex.match(string: line) { guard let testCase = generateSkippedTest(line: line) else { return } @@ -170,7 +173,7 @@ private extension JunitComponent { } private extension [JunitComponent] { - mutating func removePreviousFailingTestsAfterPassed(_ testCase: TestCase) { + mutating func removePreviousFailingTestsAfter(_ testCase: TestCase) { // base case, empty array or last is not the last passed test case guard let previousTestCase = last?.testCase, testCase.classname == previousTestCase.classname, @@ -180,7 +183,7 @@ private extension [JunitComponent] { } removeLast() // keep removing - removePreviousFailingTestsAfterPassed(testCase) + removePreviousFailingTestsAfter(testCase) } } diff --git a/Tests/XcbeautifyLibTests/JunitReporterTests.swift b/Tests/XcbeautifyLibTests/JunitReporterTests.swift index f93fbe49..1d74296d 100644 --- a/Tests/XcbeautifyLibTests/JunitReporterTests.swift +++ b/Tests/XcbeautifyLibTests/JunitReporterTests.swift @@ -462,7 +462,7 @@ class JunitReporterTests: XCTestCase { """ - func testJunitReportWithRetries() throws { + func testJunitReportWithSuccessRetry() throws { let reporter = JunitReporter() retryOnFailureTests.components(separatedBy: .newlines).forEach { reporter.add(line: $0) } let data = try reporter.generateReport() @@ -475,6 +475,77 @@ class JunitReporterTests: XCTestCase { XCTAssertEqual(xml, expectedXml) } + private let failingRetryOnFailureTests = """ + Test Suite 'All tests' started at 2021-11-05 01:08:23.237 + Test Suite 'xcbeautifyPackageTests.xctest' started at 2021-11-05 01:08:23.238 + Test Suite 'OutputHandlerTests' started at 2021-11-05 01:08:23.238 + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString]' started (Iteration 1 of 3). + /Users/andres/Git/xcbeautify/Tests/XcbeautifyLibTests/OutputHandlerTests.swift:13: error: -[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString] : XCTAssertEqual failed: ("Optional("Aggregate target Be Aggro of project AggregateExample with configuration Debug")") is not equal to ("Optional("failing Aggregate target Be Aggro of project AggregateExample with configuration Debug")") + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString]' failed (0.208 seconds). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString]' started (Iteration 2 of 3). + /Users/andres/Git/xcbeautify/Tests/XcbeautifyLibTests/OutputHandlerTests.swift:13: error: -[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString] : XCTAssertEqual failed: ("Optional("Aggregate target Be Aggro of project AggregateExample with configuration Debug")") is not equal to ("Optional("failing Aggregate target Be Aggro of project AggregateExample with configuration Debug")") + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString]' failed (0.208 seconds). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString]' started (Iteration 3 of 3). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString]' started (Iteration 2 of 3). + /Users/andres/Git/xcbeautify/Tests/XcbeautifyLibTests/OutputHandlerTests.swift:13: error: -[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString] : XCTAssertEqual failed: ("Optional("Aggregate target Be Aggro of project AggregateExample with configuration Debug")") is not equal to ("Optional("failing Aggregate target Be Aggro of project AggregateExample with configuration Debug")") + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testEarlyReturnIfEmptyString]' failed (0.208 seconds). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintAllOutputTypeByDefault]' started (Iteration 1 of 3). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintAllOutputTypeByDefault]' passed (0.000 seconds). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintOnlyTasksWithError]' started (Iteration 1 of 3). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintOnlyTasksWithError]' passed (0.000 seconds). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintOnlyTasksWithWarningOrError]' started (Iteration 1 of 3). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintOnlyTasksWithWarningOrError]' passed (0.000 seconds). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintTestResultTooIfIsCIAndQuiet]' started (Iteration 1 of 3). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintTestResultTooIfIsCIAndQuiet]' passed (0.000 seconds). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintTestResultTooIfIsCIAndQuieter]' started (Iteration 1 of 3). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintTestResultTooIfIsCIAndQuieter]' passed (0.000 seconds). + Test Suite 'OutputHandlerTests' passed at 2021-11-05 01:08:23.294. + Executed 6 tests, with 0 failures (0 unexpected) in 0.055 (0.056) seconds + """ + + private let expectedFailingTestsRetryOnFailureXml = """ + + + + + + + + + + + + + """ + + private let expectedFailingTestsRetryOnFailureLinuxXml = """ + + + + + + + + + + + + + """ + + func testJunitReportWithFailingRetries() throws { + let reporter = JunitReporter() + failingRetryOnFailureTests.components(separatedBy: .newlines).forEach { reporter.add(line: $0) } + let data = try reporter.generateReport() + let xml = String(data: data, encoding: .utf8)! + #if os(Linux) + let expectedXml = expectedFailingTestsRetryOnFailureLinuxXml + #else + let expectedXml = expectedFailingTestsRetryOnFailureXml + #endif + XCTAssertEqual(xml, expectedXml) + } + private let parallelTests = """ Test suite 'MobileWebURLRouteTest' started on 'Clone 1 of iPhone 13 mini - xctest (32505)' Test suite 'BuildFlagTests' started on 'Clone 1 of iPhone 13 mini - xctest (32507)' From 8d420dbe8d16661a1e6c95d1162d04e66de38099 Mon Sep 17 00:00:00 2001 From: Miguel Ferrando Date: Wed, 31 Jul 2024 18:23:37 +0200 Subject: [PATCH 7/9] Fix linux assertion --- Tests/XcbeautifyLibTests/JunitReporterTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/XcbeautifyLibTests/JunitReporterTests.swift b/Tests/XcbeautifyLibTests/JunitReporterTests.swift index 1d74296d..5142225c 100644 --- a/Tests/XcbeautifyLibTests/JunitReporterTests.swift +++ b/Tests/XcbeautifyLibTests/JunitReporterTests.swift @@ -522,7 +522,7 @@ class JunitReporterTests: XCTestCase { - + From c8fcf82432faafb24d0ee699b8b0103a2b49c666 Mon Sep 17 00:00:00 2001 From: Miguel Ferrando Date: Tue, 20 Aug 2024 17:14:09 +0200 Subject: [PATCH 8/9] Consider repeating tests --- Sources/XcbeautifyLib/JunitReporter.swift | 3 +- .../JunitReporterTests.swift | 59 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/Sources/XcbeautifyLib/JunitReporter.swift b/Sources/XcbeautifyLib/JunitReporter.swift index ee570af3..6607b72c 100644 --- a/Sources/XcbeautifyLib/JunitReporter.swift +++ b/Sources/XcbeautifyLib/JunitReporter.swift @@ -174,8 +174,9 @@ private extension JunitComponent { private extension [JunitComponent] { mutating func removePreviousFailingTestsAfter(_ testCase: TestCase) { - // base case, empty array or last is not the last passed test case + // base case, empty array or last is not the given TestCase guard let previousTestCase = last?.testCase, + previousTestCase.failure != nil, testCase.classname == previousTestCase.classname, testCase.name == previousTestCase.name else { diff --git a/Tests/XcbeautifyLibTests/JunitReporterTests.swift b/Tests/XcbeautifyLibTests/JunitReporterTests.swift index 5142225c..9ff077a2 100644 --- a/Tests/XcbeautifyLibTests/JunitReporterTests.swift +++ b/Tests/XcbeautifyLibTests/JunitReporterTests.swift @@ -546,6 +546,65 @@ class JunitReporterTests: XCTestCase { XCTAssertEqual(xml, expectedXml) } + private let runTestsRepeatedly = """ + Test Suite 'All tests' started at 2021-11-05 01:08:23.237 + Test Suite 'xcbeautifyPackageTests.xctest' started at 2021-11-05 01:08:23.238 + Test Suite 'OutputHandlerTests' started at 2021-11-05 01:08:23.238 + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintAllOutputTypeByDefault]' started. + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintAllOutputTypeByDefault]' passed (0.000 seconds). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintAllOutputTypeByDefault]' started. + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintAllOutputTypeByDefault]' passed (0.000 seconds). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintAllOutputTypeByDefault]' started. + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintAllOutputTypeByDefault]' passed (0.000 seconds). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintAllOutputTypeByDefault]' started. + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintAllOutputTypeByDefault]' passed (0.000 seconds). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintAllOutputTypeByDefault]' started. + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintAllOutputTypeByDefault]' passed (0.000 seconds). + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintAllOutputTypeByDefault]' started. + Test Case '-[XcbeautifyLibTests.OutputHandlerTests testPrintAllOutputTypeByDefault]' passed (0.000 seconds). + Test Suite 'OutputHandlerTests' passed at 2021-11-05 01:08:23.294. + Executed 6 tests, with 0 failures (0 unexpected) in 0.055 (0.056) seconds + """ + + private let expectedTestsRunRepeatedlyXml = """ + + + + + + + + + + + """ + + private let expectedTestsRunRepeatedlyLinuxXml = """ + + + + + + + + + + + """ + + func testJunitReportWithRepetitions() throws { + let reporter = JunitReporter() + runTestsRepeatedly.components(separatedBy: .newlines).forEach { reporter.add(line: $0) } + let data = try reporter.generateReport() + let xml = String(data: data, encoding: .utf8)! + #if os(Linux) + let expectedXml = expectedTestsRunRepeatedlyLinuxXml + #else + let expectedXml = expectedTestsRunRepeatedlyXml + #endif + XCTAssertEqual(xml, expectedXml) + } + private let parallelTests = """ Test suite 'MobileWebURLRouteTest' started on 'Clone 1 of iPhone 13 mini - xctest (32505)' Test suite 'BuildFlagTests' started on 'Clone 1 of iPhone 13 mini - xctest (32507)' From 3c653557f71bac8fdc8581a39a92797fac3ea9e7 Mon Sep 17 00:00:00 2001 From: Miguel Ferrando Date: Tue, 20 Aug 2024 17:19:04 +0200 Subject: [PATCH 9/9] Revert xcode action Add it into a separate PR --- Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Makefile b/Makefile index 53acba10..6a934797 100644 --- a/Makefile +++ b/Makefile @@ -131,7 +131,3 @@ export_coverage: .PHONY: measure measure: tools/measure - -.PHONY: xcode -xcode: - open Package.swift