-
-
Notifications
You must be signed in to change notification settings - Fork 335
feat: Add handling for Swift Testing Only Parallelization #871
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
Merged
pepicrft
merged 14 commits into
tuist:main
from
kelvinharron:add-swifttesting-parallelizable-handling
Dec 3, 2024
+168
β11
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7c6c157
add handling for swiftTestingOnly as introduced in Xcode 16
kelvinharron 39d3223
delete dead links from References
kelvinharron 7066fdd
fix formatting
kelvinharron eddd656
more formatting
kelvinharron d9af522
rename Parallelization to Parallelizable to adhere to xcode naming
kelvinharron cfc5d5e
rename Parallelization to Parallelizable to adhere to xcode naming
kelvinharron 98fe469
add init as deprecated, updated extension and removed redundant unit β¦
kelvinharron ce3a931
rename Parallelizable type to TestParallelization and make both typesβ¦
kelvinharron ef05b7f
reintroduce parallelizable from xmlElement
kelvinharron 42f69f3
fix tests using old type
kelvinharron 954369a
use computed var to best handle backwards compat with updated tests
kelvinharron 0926e9d
address lint warnings
kelvinharron 02d4647
Fix linting issues
pepicrft 58b8552
Fix linting issue
pepicrft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
Sources/XcodeProj/Scheme/XCScheme+TestParallelization.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Foundation | ||
|
||
public extension XCScheme { | ||
/// With the introduction of Swift Testing and Xcode 16, you can now choose to run your tests | ||
// in parallel across either the full suite of tests in a target with `.all`, just those created | ||
// under Swift Testing with `.swiftTestingOnly`, or run them serially with the `.none` option. | ||
enum TestParallelization: String { | ||
case all | ||
case swiftTestingOnly | ||
case none | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,13 @@ public extension XCScheme { | |
// MARK: - Attributes | ||
|
||
public var skipped: Bool | ||
public var parallelizable: Bool | ||
@available(*, deprecated, message: "Please use parallelization property instead") | ||
public var parallelizable: Bool { | ||
get { parallelization == .swiftTestingOnly } | ||
set { parallelization = newValue ? .swiftTestingOnly : .none } | ||
} | ||
|
||
public var parallelization: TestParallelization | ||
public var randomExecutionOrdering: Bool | ||
public var useTestSelectionWhitelist: Bool? | ||
public var buildableReference: BuildableReference | ||
|
@@ -16,6 +22,25 @@ public extension XCScheme { | |
|
||
// MARK: - Init | ||
|
||
public init(skipped: Bool, | ||
parallelization: TestParallelization = .none, | ||
randomExecutionOrdering: Bool = false, | ||
buildableReference: BuildableReference, | ||
locationScenarioReference: LocationScenarioReference? = nil, | ||
skippedTests: [TestItem] = [], | ||
selectedTests: [TestItem] = [], | ||
useTestSelectionWhitelist: Bool? = nil) { | ||
self.skipped = skipped | ||
self.parallelization = parallelization | ||
self.randomExecutionOrdering = randomExecutionOrdering | ||
self.buildableReference = buildableReference | ||
self.locationScenarioReference = locationScenarioReference | ||
self.useTestSelectionWhitelist = useTestSelectionWhitelist | ||
self.selectedTests = selectedTests | ||
self.skippedTests = skippedTests | ||
} | ||
|
||
@available(*, deprecated, message: "Use init with Parallelization argument instead") | ||
public init(skipped: Bool, | ||
parallelizable: Bool = false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's remove the default value, so the deprecation warning is triggered only when |
||
randomExecutionOrdering: Bool = false, | ||
|
@@ -25,7 +50,7 @@ public extension XCScheme { | |
selectedTests: [TestItem] = [], | ||
useTestSelectionWhitelist: Bool? = nil) { | ||
self.skipped = skipped | ||
self.parallelizable = parallelizable | ||
parallelization = parallelizable ? .swiftTestingOnly : .none | ||
self.randomExecutionOrdering = randomExecutionOrdering | ||
self.buildableReference = buildableReference | ||
self.locationScenarioReference = locationScenarioReference | ||
|
@@ -36,7 +61,13 @@ public extension XCScheme { | |
|
||
init(element: AEXMLElement) throws { | ||
skipped = element.attributes["skipped"] == "YES" | ||
parallelizable = element.attributes["parallelizable"] == "YES" | ||
|
||
if let parallelizableValue = element.attributes["parallelizable"] { | ||
parallelization = parallelizableValue == "YES" ? .all : .none | ||
} else { | ||
parallelization = .swiftTestingOnly | ||
} | ||
|
||
useTestSelectionWhitelist = element.attributes["useTestSelectionWhitelist"] == "YES" | ||
randomExecutionOrdering = element.attributes["testExecutionOrdering"] == "random" | ||
buildableReference = try BuildableReference(element: element["BuildableReference"]) | ||
|
@@ -63,7 +94,16 @@ public extension XCScheme { | |
|
||
func xmlElement() -> AEXMLElement { | ||
var attributes: [String: String] = ["skipped": skipped.xmlString] | ||
attributes["parallelizable"] = parallelizable ? parallelizable.xmlString : nil | ||
|
||
switch parallelization { | ||
case .all: | ||
attributes["parallelizable"] = "YES" | ||
case .none: | ||
attributes["parallelizable"] = "NO" | ||
case .swiftTestingOnly: | ||
break // SwiftTesting is inferred by the lack of a value | ||
} | ||
|
||
if let useTestSelectionWhitelist { | ||
attributes["useTestSelectionWhitelist"] = useTestSelectionWhitelist.xmlString | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.