-
Notifications
You must be signed in to change notification settings - Fork 119
Remove SPIAwareTrait and adopt TestScoping in its place #901
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
Changes from 1 commit
27770b9
f47ed31
f79bbe7
65704b5
e9b9dc9
c05542a
3b30eb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,31 +16,28 @@ | |
/// test suite, this trait causes that suite to run its contained test functions | ||
/// and sub-suites serially instead of in parallel. | ||
/// | ||
/// This trait is recursively applied: if it is applied to a suite, any | ||
/// parameterized tests or test suites contained in that suite are also | ||
/// serialized (as are any tests contained in those suites, and so on.) | ||
/// If this trait is applied to a suite, any test functions or test suites | ||
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. It's important to note that parameterized test functions are serialized (as opposed to just function A, function B, function C get serialized.) 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. I'll try to tweak the wording more. What I was attempting to clarify with this re-wording is that regular, non-parameterized test functions within a suite which has 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. I recall this being difficult to get right the last time too—might want to ping @iamleeg & friends for assistance? 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. I've pushed a new phrasing in the mean time |
||
/// contained in that suite are also serialized (as are any tests contained in | ||
/// those suites, and so on.) | ||
/// | ||
/// This trait does not affect the execution of a test relative to its peers or | ||
/// to unrelated tests. This trait has no effect if test parallelization is | ||
/// globally disabled (by, for example, passing `--no-parallel` to the | ||
/// `swift test` command.) | ||
/// | ||
/// To add this trait to a test, use ``Trait/serialized``. | ||
public struct ParallelizationTrait: TestTrait, SuiteTrait { | ||
public var isRecursive: Bool { | ||
true | ||
} | ||
} | ||
public struct ParallelizationTrait: TestTrait, SuiteTrait {} | ||
|
||
// MARK: - SPIAwareTrait | ||
// MARK: - TestScoping | ||
|
||
@_spi(ForToolsIntegrationOnly) | ||
extension ParallelizationTrait: SPIAwareTrait { | ||
public func prepare(for test: Test, action: inout Runner.Plan.Action) async throws { | ||
if case var .run(options) = action { | ||
options.isParallelizationEnabled = false | ||
action = .run(options: options) | ||
extension ParallelizationTrait: TestScoping { | ||
public func provideScope(for test: Test, testCase: Test.Case?, performing function: @Sendable () async throws -> Void) async throws { | ||
guard var configuration = Configuration.current else { | ||
throw SystemError(description: "There is no current Configuration when attempting to provide scope for test '\(test.name)'") | ||
stmontgomery marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
configuration.isParallelizationEnabled = false | ||
try await Configuration.withCurrent(configuration, perform: function) | ||
} | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.