Skip to content

Commit

Permalink
rename Parallelization to Parallelizable to adhere to xcode naming
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinharron committed Oct 19, 2024
1 parent 8bce2ca commit f2919e5
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 23 deletions.
18 changes: 18 additions & 0 deletions Sources/XcodeProj/Scheme/XCScheme+TestableReference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ public extension XCScheme {
self.selectedTests = selectedTests
self.skippedTests = skippedTests
}

public init(skipped: Bool,
parallelizable: Bool = false,
randomExecutionOrdering: Bool = false,
buildableReference: BuildableReference,
locationScenarioReference: LocationScenarioReference? = nil,
skippedTests: [TestItem] = [],
selectedTests: [TestItem] = [],
useTestSelectionWhitelist: Bool? = nil) {
self.skipped = skipped
self.parallelizable = parallelizable ? .all : .none
self.randomExecutionOrdering = randomExecutionOrdering
self.buildableReference = buildableReference
self.locationScenarioReference = locationScenarioReference
self.useTestSelectionWhitelist = useTestSelectionWhitelist
self.selectedTests = selectedTests
self.skippedTests = skippedTests
}

init(element: AEXMLElement) throws {
skipped = element.attributes["skipped"] == "YES"
Expand Down
96 changes: 73 additions & 23 deletions Tests/XcodeProjTests/Scheme/XCSchemeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ final class XCSchemeIntegrationTests: XCTestCase {
}
}

func test_read_iosScheme_noParallelizable_setsswiftTestingOnly() throws {
let scheme = try XCScheme(path: iosSchemePath)

XCTAssertEqual(scheme.testAction?.testables.first?.parallelizable, .swiftTestingOnly)
}

func test_write_minimalScheme() {
testWrite(from: minimalSchemePath,
initModel: { try? XCScheme(path: $0) },
Expand Down Expand Up @@ -85,7 +91,7 @@ final class XCSchemeIntegrationTests: XCTestCase {
XCTAssertNil(subject.attributes["useTestSelectionWhitelist"])
}

func test_write_testableReferenceAttributesValues() {
func test_write_testableReferenceAttributesValues_allParallelizable() {
let reference = XCScheme.TestableReference(
skipped: false,
parallelizable: .all,
Expand All @@ -106,28 +112,72 @@ final class XCSchemeIntegrationTests: XCTestCase {
XCTAssertEqual(subject.attributes["useTestSelectionWhitelist"], "YES")
XCTAssertEqual(subject.attributes["testExecutionOrdering"], "random")
}

func test_write_testableReferenceAttributesValuesForSwiftTesting() {
let reference = XCScheme.TestableReference(
skipped: false,
parallelizable: .swiftTestingOnly,
randomExecutionOrdering: true,
buildableReference: XCScheme.BuildableReference(
referencedContainer: "",
blueprint: PBXObject(),
buildableName: "",
blueprintName: ""
),
skippedTests: [],
selectedTests: [],
useTestSelectionWhitelist: true
)
let subject = reference.xmlElement()
XCTAssertEqual(subject.attributes["skipped"], "NO")
XCTAssertNil(subject.attributes["parallelizable"])
XCTAssertEqual(subject.attributes["useTestSelectionWhitelist"], "YES")
XCTAssertEqual(subject.attributes["testExecutionOrdering"], "random")
}

func test_write_testableReferenceAttributesValues_noneParallelizable() {
let reference = XCScheme.TestableReference(
skipped: false,
parallelizable: .none,
randomExecutionOrdering: true,
buildableReference: XCScheme.BuildableReference(
referencedContainer: "",
blueprint: PBXObject(),
buildableName: "",
blueprintName: ""
),
skippedTests: [],
selectedTests: [],
useTestSelectionWhitelist: true
)
let subject = reference.xmlElement()
XCTAssertEqual(subject.attributes["skipped"], "NO")
XCTAssertEqual(subject.attributes["parallelizable"], "NO")
XCTAssertEqual(subject.attributes["useTestSelectionWhitelist"], "YES")
XCTAssertEqual(subject.attributes["testExecutionOrdering"], "random")
}

func test_write_testableReferenceAttributesValues_trueParallelizable() {
let reference = XCScheme.TestableReference(
skipped: false,
parallelizable: true,
randomExecutionOrdering: true,
buildableReference: XCScheme.BuildableReference(
referencedContainer: "",
blueprint: PBXObject(),
buildableName: "",
blueprintName: ""
),
skippedTests: [],
selectedTests: [],
useTestSelectionWhitelist: true
)
let subject = reference.xmlElement()
XCTAssertEqual(subject.attributes["skipped"], "NO")
XCTAssertEqual(subject.attributes["parallelizable"], "YES")
XCTAssertEqual(subject.attributes["useTestSelectionWhitelist"], "YES")
XCTAssertEqual(subject.attributes["testExecutionOrdering"], "random")
}

func test_write_testableReferenceAttributesValues_falseParallelizable() {
let reference = XCScheme.TestableReference(
skipped: false,
parallelizable: false,
randomExecutionOrdering: true,
buildableReference: XCScheme.BuildableReference(
referencedContainer: "",
blueprint: PBXObject(),
buildableName: "",
blueprintName: ""
),
skippedTests: [],
selectedTests: [],
useTestSelectionWhitelist: true
)
let subject = reference.xmlElement()
XCTAssertEqual(subject.attributes["skipped"], "NO")
XCTAssertEqual(subject.attributes["parallelizable"], "NO")
XCTAssertEqual(subject.attributes["useTestSelectionWhitelist"], "YES")
XCTAssertEqual(subject.attributes["testExecutionOrdering"], "random")
}

func test_write_testableReferenceSelectedTests() {
// Given
Expand Down

0 comments on commit f2919e5

Please sign in to comment.