Skip to content

Commit

Permalink
Run on cloud runners (#14)
Browse files Browse the repository at this point in the history
* Run on cloud runners

* Using new macos and xcode

* Fixed locale in tests
  • Loading branch information
AllDmeat authored Dec 15, 2023
1 parent 22ad06a commit fb6d913
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:
jobs:
tests:

runs-on: 'ios'
runs-on: 'macos-13'
timeout-minutes: 10

steps:
Expand Down
2 changes: 1 addition & 1 deletion .xcode-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.3
15
5 changes: 5 additions & 0 deletions Sources/DBXCResultParser/Formatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import Foundation

class Formatter {
static var locale: Locale?

static func format(_ report: ReportModel,
filters: [Parser.Filter] = [],
format: Parser.Format) -> String {
Expand Down Expand Up @@ -171,13 +173,15 @@ extension String {
extension MeasurementFormatter {
static var singleTestDurationFormatter: MeasurementFormatter {
let formatter = MeasurementFormatter()
formatter.locale = Formatter.locale
formatter.unitOptions = [.providedUnit]
formatter.numberFormatter.maximumFractionDigits = 0
return formatter
}

static var totalTestsDurationFormatter: MeasurementFormatter {
let formatter = MeasurementFormatter()
formatter.locale = Formatter.locale
formatter.unitOptions = [.naturalScale]
formatter.numberFormatter.maximumFractionDigits = 0
return formatter
Expand All @@ -187,6 +191,7 @@ extension MeasurementFormatter {
extension NumberFormatter {
static var testsCountFormatter: NumberFormatter {
let formatter = NumberFormatter()
formatter.locale = Formatter.locale
formatter.maximumFractionDigits = 0
return formatter
}
Expand Down
14 changes: 12 additions & 2 deletions Tests/DBXCResultParserTests/FormatterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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() {
Expand Down
12 changes: 7 additions & 5 deletions Tests/DBXCResultParserTests/IntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand All @@ -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 {
Expand Down

0 comments on commit fb6d913

Please sign in to comment.