From 39d05784edf84eed3ce3ef01a1bc36a3c2ff43e1 Mon Sep 17 00:00:00 2001 From: Aleksey Berezka Date: Fri, 15 Dec 2023 15:36:35 +0500 Subject: [PATCH 1/3] Run on cloud runners --- .github/workflows/unittest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 42b965c..4c943bc 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -19,7 +19,7 @@ env: jobs: tests: - runs-on: 'ios' + runs-on: 'macos-latest' timeout-minutes: 10 steps: From f1324c44af2bca4f1a358327730f4005273dcbe3 Mon Sep 17 00:00:00 2001 From: Aleksey Berezka Date: Fri, 15 Dec 2023 16:09:27 +0500 Subject: [PATCH 2/3] Using new macos and xcode --- .github/workflows/unittest.yml | 2 +- .xcode-version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 4c943bc..1dd678d 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -19,7 +19,7 @@ env: jobs: tests: - runs-on: 'macos-latest' + runs-on: 'macos-13' timeout-minutes: 10 steps: diff --git a/.xcode-version b/.xcode-version index c519231..3f10ffe 100644 --- a/.xcode-version +++ b/.xcode-version @@ -1 +1 @@ -14.3 \ No newline at end of file +15 \ No newline at end of file From 4743cc61b9fdce7dcee0b05179ae0c78eb09e16f Mon Sep 17 00:00:00 2001 From: Aleksey Berezka Date: Fri, 15 Dec 2023 16:19:50 +0500 Subject: [PATCH 3/3] Fixed locale in tests --- Sources/DBXCResultParser/Formatter.swift | 5 +++++ Tests/DBXCResultParserTests/FormatterTests.swift | 14 ++++++++++++-- Tests/DBXCResultParserTests/IntegrationTests.swift | 12 +++++++----- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Sources/DBXCResultParser/Formatter.swift b/Sources/DBXCResultParser/Formatter.swift index 92027bc..705e209 100644 --- a/Sources/DBXCResultParser/Formatter.swift +++ b/Sources/DBXCResultParser/Formatter.swift @@ -8,6 +8,8 @@ import Foundation class Formatter { + static var locale: Locale? + static func format(_ report: ReportModel, filters: [Parser.Filter] = [], format: Parser.Format) -> String { @@ -171,6 +173,7 @@ extension String { extension MeasurementFormatter { static var singleTestDurationFormatter: MeasurementFormatter { let formatter = MeasurementFormatter() + formatter.locale = Formatter.locale formatter.unitOptions = [.providedUnit] formatter.numberFormatter.maximumFractionDigits = 0 return formatter @@ -178,6 +181,7 @@ extension MeasurementFormatter { static var totalTestsDurationFormatter: MeasurementFormatter { let formatter = MeasurementFormatter() + formatter.locale = Formatter.locale formatter.unitOptions = [.naturalScale] formatter.numberFormatter.maximumFractionDigits = 0 return formatter @@ -187,6 +191,7 @@ extension MeasurementFormatter { extension NumberFormatter { static var testsCountFormatter: NumberFormatter { let formatter = NumberFormatter() + formatter.locale = Formatter.locale formatter.maximumFractionDigits = 0 return formatter } diff --git a/Tests/DBXCResultParserTests/FormatterTests.swift b/Tests/DBXCResultParserTests/FormatterTests.swift index e488703..79a5993 100644 --- a/Tests/DBXCResultParserTests/FormatterTests.swift +++ b/Tests/DBXCResultParserTests/FormatterTests.swift @@ -2,6 +2,16 @@ import XCTest @testable import DBXCResultParser final class FormatterTests: XCTestCase { + override func setUpWithError() throws { + try super.setUpWithError() + Formatter.locale = Locale(identifier: "en-US") + } + + override func tearDownWithError() throws { + Formatter.locale = nil + try super.tearDownWithError() + } + func test_filter_any_list() { let result = Formatter.format(generalReport, format: .list) @@ -38,12 +48,12 @@ NetworkSpec func test_filter_any_count() { let result = Formatter.format(generalReport, format: .count) - XCTAssertEqual(result, "7 (0 secs)") + XCTAssertEqual(result, "7 (0 sec)") } func test_filter_failure_count() { let result = Formatter.format(generalReport, filters: [.failed], format: .count) - XCTAssertEqual(result, "3 (0 secs)") + XCTAssertEqual(result, "3 (0 sec)") } func test_filter_slow_list_milliseconds() { diff --git a/Tests/DBXCResultParserTests/IntegrationTests.swift b/Tests/DBXCResultParserTests/IntegrationTests.swift index 38dc2c7..85272e6 100644 --- a/Tests/DBXCResultParserTests/IntegrationTests.swift +++ b/Tests/DBXCResultParserTests/IntegrationTests.swift @@ -4,9 +4,11 @@ import XCTest final class IntegrationTests: XCTestCase { override func setUpWithError() throws { try super.setUpWithError() + Formatter.locale = Locale(identifier: "en-US") } override func tearDownWithError() throws { + Formatter.locale = nil try super.tearDownWithError() } @@ -25,25 +27,25 @@ final class IntegrationTests: XCTestCase { let result = try Parser(xcresultPath: Constants.unitTestsReportPath).parse(filters: [.slow(duration: .init(value: 3, unit: .seconds))], format: .list) let expectedResult = """ ContactsViewControllerSpec - ✅🕢 (3 secs) ContactsViewController__load_view__when_feedback_block_are_visible__when_chat_enabled__should_snapshot() - ✅🕢 (3 secs) ContactsViewController__load_view__when_location_button_is_visible__should_snapshot() + ✅🕢 (3 sec) ContactsViewController__load_view__when_feedback_block_are_visible__when_chat_enabled__should_snapshot() + ✅🕢 (3 sec) ContactsViewController__load_view__when_location_button_is_visible__should_snapshot() """ XCTAssertEqual(String(result.prefix(expectedResult.count)), expectedResult) } func test_parse_slow_3s_count() throws { let result = try Parser(xcresultPath: Constants.unitTestsReportPath).parse(filters: [.slow(duration: .init(value: 3, unit: .seconds))], format: .count) - XCTAssertEqual(result, "2 (7 secs)") + XCTAssertEqual(result, "2 (7 sec)") } func test_parse_failed_count() throws { let result = try Parser(xcresultPath: Constants.unitTestsReportPath).parse(filters: [.failed], format: .count) - XCTAssertEqual(result, "77 (9 secs)") + XCTAssertEqual(result, "77 (9 sec)") } func test_parse_failed_slow_3s_count() throws { let result = try Parser(xcresultPath: Constants.unitTestsReportPath).parse(filters: [.failed, .slow(duration: .init(value: 3, unit: .seconds))], format: .count) - XCTAssertEqual(result, "79 (16 secs)") + XCTAssertEqual(result, "79 (16 sec)") } func test_parse_any_count() throws {