Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run on cloud runners #14

Merged
merged 3 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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