@@ -65,11 +65,7 @@ public actor SkipUnless {
65
65
// Never skip tests in CI. Toolchain should be up-to-date
66
66
checkResult = . featureSupported
67
67
} else {
68
- guard let swiftc = await ToolchainRegistry . forTesting. default? . swiftc else {
69
- throw SwiftVersionParsingError . failedToFindSwiftc
70
- }
71
-
72
- let toolchainSwiftVersion = try await getSwiftVersion ( swiftc)
68
+ let toolchainSwiftVersion = try await unwrap ( ToolchainRegistry . forTesting. default) . swiftVersion
73
69
let requiredSwiftVersion = SwiftVersion ( swiftVersion. major, swiftVersion. minor)
74
70
if toolchainSwiftVersion < requiredSwiftVersion {
75
71
checkResult = . featureUnsupported(
@@ -174,10 +170,6 @@ public actor SkipUnless {
174
170
175
171
/// SwiftPM moved the location where it stores Swift modules to a subdirectory in
176
172
/// https://github.com/apple/swift-package-manager/pull/7103.
177
- ///
178
- /// sourcekit-lsp uses the built-in SwiftPM to synthesize compiler arguments and cross-module tests fail if the host
179
- /// toolchain’s SwiftPM stores the Swift modules on the top level but we synthesize compiler arguments expecting the
180
- /// modules to be in a `Modules` subdirectory.
181
173
public static func swiftpmStoresModulesInSubdirectory(
182
174
file: StaticString = #filePath,
183
175
line: UInt = #line
@@ -297,60 +289,3 @@ fileprivate extension String {
297
289
}
298
290
}
299
291
}
300
-
301
- /// A Swift version consisting of the major and minor component.
302
- fileprivate struct SwiftVersion : Comparable , CustomStringConvertible {
303
- let major : Int
304
- let minor : Int
305
-
306
- static func < ( lhs: SwiftVersion , rhs: SwiftVersion ) -> Bool {
307
- return ( lhs. major, lhs. minor) < ( rhs. major, rhs. minor)
308
- }
309
-
310
- init ( _ major: Int , _ minor: Int ) {
311
- self . major = major
312
- self . minor = minor
313
- }
314
-
315
- var description : String {
316
- return " \( major) . \( minor) "
317
- }
318
- }
319
-
320
- fileprivate enum SwiftVersionParsingError : Error , CustomStringConvertible {
321
- case failedToFindSwiftc
322
- case failedToParseOutput( output: String ? )
323
-
324
- var description : String {
325
- switch self {
326
- case . failedToFindSwiftc:
327
- return " Default toolchain does not contain a swiftc executable "
328
- case . failedToParseOutput( let output) :
329
- return """
330
- Failed to parse Swift version. Output of swift --version:
331
- \( output ?? " <empty> " )
332
- """
333
- }
334
- }
335
- }
336
-
337
- /// Return the major and minor version of Swift for a `swiftc` compiler at `swiftcPath`.
338
- private func getSwiftVersion( _ swiftcPath: AbsolutePath ) async throws -> SwiftVersion {
339
- let process = Process ( args: swiftcPath. pathString, " --version " )
340
- try process. launch ( )
341
- let result = try await process. waitUntilExit ( )
342
- let output = String ( bytes: try result. output. get ( ) , encoding: . utf8)
343
- let regex = Regex {
344
- " Swift version "
345
- Capture { OneOrMore ( . digit) }
346
- " . "
347
- Capture { OneOrMore ( . digit) }
348
- }
349
- guard let match = output? . firstMatch ( of: regex) else {
350
- throw SwiftVersionParsingError . failedToParseOutput ( output: output)
351
- }
352
- guard let major = Int ( match. 1 ) , let minor = Int ( match. 2 ) else {
353
- throw SwiftVersionParsingError . failedToParseOutput ( output: output)
354
- }
355
- return SwiftVersion ( major, minor)
356
- }
0 commit comments