Skip to content

Commit ac0a1ce

Browse files
committed
Adopt new Swift Testing custom traits API
This is the official replacement for the SPI that was previously being used. This will regain the test coverage of any functions which use these traits, which have been skipped for a while.
1 parent 64d4b57 commit ac0a1ce

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

Diff for: Package.swift

+1-4
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,7 @@ let package = Package(
257257
.target(
258258
name: "SWBTestSupport",
259259
dependencies: ["SwiftBuild", "SWBBuildSystem", "SWBCore", "SWBTaskConstruction", "SWBTaskExecution", "SWBUtil", "SWBLLBuild", "SWBMacro"],
260-
swiftSettings: swiftSettings(languageMode: .v5) + [
261-
// Temporary until swift-testing introduces replacement for this SPI
262-
.define("DONT_HAVE_CUSTOM_EXECUTION_TRAIT")
263-
]),
260+
swiftSettings: swiftSettings(languageMode: .v5)),
264261

265262
// Tests
266263
.testTarget(

Diff for: Sources/SWBTestSupport/KnownIssueTestSupport.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if DONT_HAVE_CUSTOM_EXECUTION_TRAIT
13+
#if compiler(<6.1)
1414
public import Testing
1515

1616
extension Trait where Self == Testing.ConditionTrait {
@@ -23,9 +23,9 @@ extension Trait where Self == Testing.ConditionTrait {
2323
}
2424
}
2525
#else
26-
@_spi(Experimental) package import Testing
26+
package import Testing
2727

28-
package struct KnownIssueTestTrait: CustomExecutionTrait & TestTrait & SuiteTrait {
28+
package struct KnownIssueTestTrait: TestTrait & SuiteTrait & TestScoping {
2929
let comment: Comment
3030
let isIntermittent: Bool
3131
let sourceLocation: SourceLocation
@@ -34,7 +34,7 @@ package struct KnownIssueTestTrait: CustomExecutionTrait & TestTrait & SuiteTrai
3434
true
3535
}
3636

37-
@Sendable package func execute(_ function: @escaping @Sendable () async throws -> Void, for test: Testing.Test, testCase: Testing.Test.Case?) async throws {
37+
package func provideScope(for test: Testing.Test, testCase: Testing.Test.Case?, performing function: @Sendable () async throws -> Void) async throws {
3838
if testCase == nil || test.isSuite {
3939
try await function()
4040
} else {

Diff for: Sources/SWBTestSupport/UserDefaultTestTrait.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if DONT_HAVE_CUSTOM_EXECUTION_TRAIT
13+
#if compiler(<6.1)
1414
public import Testing
1515

1616
extension Trait where Self == Testing.ConditionTrait {
@@ -19,19 +19,19 @@ extension Trait where Self == Testing.ConditionTrait {
1919
}
2020
}
2121
#else
22-
@_spi(Experimental) package import Testing
22+
package import Testing
2323
@_spi(Testing) import SWBUtil
2424
import Foundation
2525

26-
package struct UserDefaultsTestTrait: CustomExecutionTrait & TestTrait & SuiteTrait {
26+
package struct UserDefaultsTestTrait: TestTrait & SuiteTrait & TestScoping {
2727
let userDefaults: [String: String]
2828
let clean: Bool
2929

3030
package var isRecursive: Bool {
3131
true
3232
}
3333

34-
@Sendable package func execute(_ function: @escaping @Sendable () async throws -> Void, for test: Testing.Test, testCase: Testing.Test.Case?) async throws {
34+
package func provideScope(for test: Testing.Test, testCase: Testing.Test.Case?, performing function: @Sendable () async throws -> Void) async throws {
3535
if testCase == nil || test.isSuite {
3636
try await function()
3737
} else {

Diff for: Tests/SWBBuildSystemTests/BuildTaskBehaviorTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ fileprivate struct BuildTaskBehaviorTests: CoreBasedTests {
206206

207207
/// Stress concurrent access to the build system cache during rapid cancel
208208
/// then build scenarios.
209-
@Test(.requireSDKs(.host),
209+
@Test(.requireSDKs(.host), .skipHostOS(.windows, "no /usr/bin/true"),
210210
// To aid in establishing the subtle concurrent
211211
// timing required to trigger chaos, we disable early build operation
212212
// cancellation.

0 commit comments

Comments
 (0)