@@ -27,14 +27,16 @@ import enum TSCBasic.ProcessEnv
27
27
// MARK: - Skip checks
28
28
29
29
/// Namespace for functions that are used to skip unsupported tests.
30
- public enum SkipUnless {
30
+ public actor SkipUnless {
31
31
private enum FeatureCheckResult {
32
32
case featureSupported
33
33
case featureUnsupported( skipMessage: String )
34
34
}
35
35
36
+ private static let shared = SkipUnless ( )
37
+
36
38
/// For any feature that has already been evaluated, the result of whether or not it should be skipped.
37
- private static var checkCache : [ String : FeatureCheckResult ] = [ : ]
39
+ private var checkCache : [ String : FeatureCheckResult ] = [ : ]
38
40
39
41
/// Throw an `XCTSkip` if any of the following conditions hold
40
42
/// - The Swift version of the toolchain used for testing (`ToolchainRegistry.forTesting.default`) is older than
@@ -49,7 +51,7 @@ public enum SkipUnless {
49
51
///
50
52
/// Independently of these checks, the tests are never skipped in Swift CI (identified by the presence of the `SWIFTCI_USE_LOCAL_DEPS` environment). Swift CI is assumed to always build its own toolchain, which is thus
51
53
/// guaranteed to be up-to-date.
52
- private static func skipUnlessSupportedByToolchain(
54
+ private func skipUnlessSupportedByToolchain(
53
55
swiftVersion: SwiftVersion ,
54
56
featureName: String = #function,
55
57
file: StaticString ,
@@ -96,10 +98,10 @@ public enum SkipUnless {
96
98
}
97
99
98
100
public static func sourcekitdHasSemanticTokensRequest(
99
- file: StaticString = #file ,
101
+ file: StaticString = #filePath ,
100
102
line: UInt = #line
101
103
) async throws {
102
- try await skipUnlessSupportedByToolchain ( swiftVersion: SwiftVersion ( 5 , 11 ) , file: file, line: line) {
104
+ try await shared . skipUnlessSupportedByToolchain ( swiftVersion: SwiftVersion ( 5 , 11 ) , file: file, line: line) {
103
105
let testClient = try await TestSourceKitLSPClient ( )
104
106
let uri = DocumentURI . for ( . swift)
105
107
testClient. openDocument ( " 0.bitPattern " , uri: uri)
@@ -127,10 +129,10 @@ public enum SkipUnless {
127
129
}
128
130
129
131
public static func sourcekitdSupportsRename(
130
- file: StaticString = #file ,
132
+ file: StaticString = #filePath ,
131
133
line: UInt = #line
132
134
) async throws {
133
- try await skipUnlessSupportedByToolchain ( swiftVersion: SwiftVersion ( 5 , 11 ) , file: file, line: line) {
135
+ try await shared . skipUnlessSupportedByToolchain ( swiftVersion: SwiftVersion ( 5 , 11 ) , file: file, line: line) {
134
136
let testClient = try await TestSourceKitLSPClient ( )
135
137
let uri = DocumentURI . for ( . swift)
136
138
let positions = testClient. openDocument ( " func 1️⃣test() {} " , uri: uri)
@@ -147,10 +149,10 @@ public enum SkipUnless {
147
149
148
150
/// Whether clangd has support for the `workspace/indexedRename` request.
149
151
public static func clangdSupportsIndexBasedRename(
150
- file: StaticString = #file ,
152
+ file: StaticString = #filePath ,
151
153
line: UInt = #line
152
154
) async throws {
153
- try await skipUnlessSupportedByToolchain ( swiftVersion: SwiftVersion ( 5 , 11 ) , file: file, line: line) {
155
+ try await shared . skipUnlessSupportedByToolchain ( swiftVersion: SwiftVersion ( 5 , 11 ) , file: file, line: line) {
154
156
let testClient = try await TestSourceKitLSPClient ( )
155
157
let uri = DocumentURI . for ( . c)
156
158
let positions = testClient. openDocument ( " void 1️⃣test() {} " , uri: uri)
@@ -177,10 +179,10 @@ public enum SkipUnless {
177
179
/// toolchain’s SwiftPM stores the Swift modules on the top level but we synthesize compiler arguments expecting the
178
180
/// modules to be in a `Modules` subdirectory.
179
181
public static func swiftpmStoresModulesInSubdirectory(
180
- file: StaticString = #file ,
182
+ file: StaticString = #filePath ,
181
183
line: UInt = #line
182
184
) async throws {
183
- try await skipUnlessSupportedByToolchain ( swiftVersion: SwiftVersion ( 5 , 11 ) , file: file, line: line) {
185
+ try await shared . skipUnlessSupportedByToolchain ( swiftVersion: SwiftVersion ( 5 , 11 ) , file: file, line: line) {
184
186
let workspace = try await SwiftPMTestProject (
185
187
files: [ " test.swift " : " " ] ,
186
188
build: true
@@ -195,21 +197,21 @@ public enum SkipUnless {
195
197
}
196
198
197
199
public static func toolchainContainsSwiftFormat(
198
- file: StaticString = #file ,
200
+ file: StaticString = #filePath ,
199
201
line: UInt = #line
200
202
) async throws {
201
- try await skipUnlessSupportedByToolchain ( swiftVersion: SwiftVersion ( 5 , 11 ) , file: file, line: line) {
203
+ try await shared . skipUnlessSupportedByToolchain ( swiftVersion: SwiftVersion ( 5 , 11 ) , file: file, line: line) {
202
204
return await ToolchainRegistry . forTesting. default? . swiftFormat != nil
203
205
}
204
206
}
205
207
206
208
public static func sourcekitdReturnsRawDocumentationResponse(
207
- file: StaticString = #file ,
209
+ file: StaticString = #filePath ,
208
210
line: UInt = #line
209
211
) async throws {
210
212
struct ExpectedMarkdownContentsError : Error { }
211
213
212
- return try await skipUnlessSupportedByToolchain ( swiftVersion: SwiftVersion ( 6 , 0 ) , file: file, line: line) {
214
+ return try await shared . skipUnlessSupportedByToolchain ( swiftVersion: SwiftVersion ( 6 , 0 ) , file: file, line: line) {
213
215
// The XML-based doc comment conversion did not preserve `Precondition`.
214
216
let testClient = try await TestSourceKitLSPClient ( )
215
217
let uri = DocumentURI . for ( . swift)
@@ -235,10 +237,10 @@ public enum SkipUnless {
235
237
/// Checks whether the index contains a fix that prevents it from adding relations to non-indexed locals
236
238
/// (https://github.com/apple/swift/pull/72930).
237
239
public static func indexOnlyHasContainedByRelationsToIndexedDecls(
238
- file: StaticString = #file ,
240
+ file: StaticString = #filePath ,
239
241
line: UInt = #line
240
242
) async throws {
241
- return try await skipUnlessSupportedByToolchain ( swiftVersion: SwiftVersion ( 6 , 0 ) , file: file, line: line) {
243
+ return try await shared . skipUnlessSupportedByToolchain ( swiftVersion: SwiftVersion ( 6 , 0 ) , file: file, line: line) {
242
244
let project = try await IndexedSingleSwiftFileTestProject (
243
245
"""
244
246
func foo() {}
0 commit comments