@@ -15,28 +15,54 @@ import SKTestSupport
1515import ToolchainRegistry
1616import XCTest
1717
18- final class CodeLensTests : XCTestCase {
18+ fileprivate extension Toolchain {
19+ #if compiler(>=6.4)
20+ #warning(
21+ " Once we require swift-play in the toolchain that's used to test SourceKit-LSP, we can just use `forTesting` "
22+ )
23+ #endif
24+ static var forTestingWithSwiftPlay : Toolchain {
25+ get async throws {
26+ let toolchain = try await unwrap ( ToolchainRegistry . forTesting. default)
27+ return Toolchain (
28+ identifier: " \( toolchain. identifier) -swift-swift " ,
29+ displayName: " \( toolchain. identifier) with swift-play " ,
30+ path: toolchain. path,
31+ clang: toolchain. clang,
32+ swift: toolchain. swift,
33+ swiftc: toolchain. swiftc,
34+ swiftPlay: URL ( fileURLWithPath: " /dummy/usr/bin/swift-play " ) ,
35+ clangd: toolchain. clangd,
36+ sourcekitd: toolchain. sourcekitd,
37+ sourceKitClientPlugin: toolchain. sourceKitClientPlugin,
38+ sourceKitServicePlugin: toolchain. sourceKitServicePlugin,
39+ libIndexStore: toolchain. libIndexStore
40+ )
41+ }
42+ }
1943
20- var toolchain : Toolchain !
21- var toolchainWithSwiftPlay : Toolchain !
22-
23- override func setUp( ) async throws {
24- toolchain = try await unwrap ( ToolchainRegistry . forTesting. default)
25- toolchainWithSwiftPlay = Toolchain (
26- identifier: " \( toolchain. identifier) -swift-swift " ,
27- displayName: " \( toolchain. identifier) with swift-play " ,
28- path: toolchain. path,
29- clang: toolchain. clang,
30- swift: toolchain. swift,
31- swiftc: toolchain. swiftc,
32- swiftPlay: URL ( fileURLWithPath: " /dummy/usr/bin/swift-play " ) ,
33- clangd: toolchain. clangd,
34- sourcekitd: toolchain. sourcekitd,
35- sourceKitClientPlugin: toolchain. sourceKitClientPlugin,
36- sourceKitServicePlugin: toolchain. sourceKitServicePlugin,
37- libIndexStore: toolchain. libIndexStore
38- )
44+ static var forTestingWithoutSwiftPlay : Toolchain {
45+ get async throws {
46+ let toolchain = try await unwrap ( ToolchainRegistry . forTesting. default)
47+ return Toolchain (
48+ identifier: " \( toolchain. identifier) -no-swift-swift " ,
49+ displayName: " \( toolchain. identifier) without swift-play " ,
50+ path: toolchain. path,
51+ clang: toolchain. clang,
52+ swift: toolchain. swift,
53+ swiftc: toolchain. swiftc,
54+ swiftPlay: nil ,
55+ clangd: toolchain. clangd,
56+ sourcekitd: toolchain. sourcekitd,
57+ sourceKitClientPlugin: toolchain. sourceKitClientPlugin,
58+ sourceKitServicePlugin: toolchain. sourceKitServicePlugin,
59+ libIndexStore: toolchain. libIndexStore
60+ )
61+ }
3962 }
63+ }
64+
65+ final class CodeLensTests : XCTestCase {
4066
4167 func testNoLenses( ) async throws {
4268 var codeLensCapabilities = TextDocumentClientCapabilities . CodeLens ( )
@@ -66,7 +92,7 @@ final class CodeLensTests: XCTestCase {
6692 }
6793
6894 func testNoClientCodeLenses( ) async throws {
69- let toolchainRegistry = ToolchainRegistry ( toolchains: [ toolchainWithSwiftPlay ] )
95+ let toolchainRegistry = ToolchainRegistry ( toolchains: [ try await Toolchain . forTestingWithSwiftPlay ] )
7096 let project = try await SwiftPMTestProject (
7197 files: [
7298 " Test.swift " : """
@@ -105,7 +131,7 @@ final class CodeLensTests: XCTestCase {
105131 SupportedCodeLensCommand . play: " swift.play " ,
106132 ]
107133 let capabilities = ClientCapabilities ( textDocument: TextDocumentClientCapabilities ( codeLens: codeLensCapabilities) )
108- let toolchainRegistry = ToolchainRegistry ( toolchains: [ toolchainWithSwiftPlay ] )
134+ let toolchainRegistry = ToolchainRegistry ( toolchains: [ try await Toolchain . forTestingWithSwiftPlay ] )
109135
110136 let project = try await SwiftPMTestProject (
111137 files: [
@@ -194,7 +220,7 @@ final class CodeLensTests: XCTestCase {
194220 SupportedCodeLensCommand . play: " swift.play "
195221 ]
196222 let capabilities = ClientCapabilities ( textDocument: TextDocumentClientCapabilities ( codeLens: codeLensCapabilities) )
197- let toolchainRegistry = ToolchainRegistry ( toolchains: [ toolchainWithSwiftPlay ] )
223+ let toolchainRegistry = ToolchainRegistry ( toolchains: [ try await Toolchain . forTestingWithSwiftPlay ] )
198224
199225 let project = try await SwiftPMTestProject (
200226 files: [
@@ -256,21 +282,7 @@ final class CodeLensTests: XCTestCase {
256282 SupportedCodeLensCommand . play: " swift.play " ,
257283 ]
258284 let capabilities = ClientCapabilities ( textDocument: TextDocumentClientCapabilities ( codeLens: codeLensCapabilities) )
259- let toolchainWithoutSwiftPlay = Toolchain (
260- identifier: " \( toolchain. identifier) -swift-swift " ,
261- displayName: " \( toolchain. identifier) with swift-play " ,
262- path: toolchain. path,
263- clang: toolchain. clang,
264- swift: toolchain. swift,
265- swiftc: toolchain. swiftc,
266- swiftPlay: nil ,
267- clangd: toolchain. clangd,
268- sourcekitd: toolchain. sourcekitd,
269- sourceKitClientPlugin: toolchain. sourceKitClientPlugin,
270- sourceKitServicePlugin: toolchain. sourceKitServicePlugin,
271- libIndexStore: toolchain. libIndexStore
272- )
273- let toolchainRegistry = ToolchainRegistry ( toolchains: [ toolchainWithoutSwiftPlay] )
285+ let toolchainRegistry = ToolchainRegistry ( toolchains: [ try await Toolchain . forTestingWithoutSwiftPlay] )
274286
275287 let project = try await SwiftPMTestProject (
276288 files: [
@@ -331,7 +343,7 @@ final class CodeLensTests: XCTestCase {
331343 SupportedCodeLensCommand . play: " swift.play "
332344 ]
333345 let capabilities = ClientCapabilities ( textDocument: TextDocumentClientCapabilities ( codeLens: codeLensCapabilities) )
334- let toolchainRegistry = ToolchainRegistry ( toolchains: [ toolchainWithSwiftPlay ] )
346+ let toolchainRegistry = ToolchainRegistry ( toolchains: [ try await Toolchain . forTestingWithSwiftPlay ] )
335347 let project = try await SwiftPMTestProject (
336348 files: [
337349 " Sources/MyLibrary/Test.swift " : """
@@ -375,7 +387,7 @@ final class CodeLensTests: XCTestCase {
375387 SupportedCodeLensCommand . play: " swift.play "
376388 ]
377389 let capabilities = ClientCapabilities ( textDocument: TextDocumentClientCapabilities ( codeLens: codeLensCapabilities) )
378- let toolchainRegistry = ToolchainRegistry ( toolchains: [ toolchainWithSwiftPlay ] )
390+ let toolchainRegistry = ToolchainRegistry ( toolchains: [ try await Toolchain . forTestingWithSwiftPlay ] )
379391 let project = try await SwiftPMTestProject (
380392 files: [
381393 " Sources/MyLibrary/Test.swift " : """
0 commit comments