@@ -65,11 +65,7 @@ public actor SkipUnless {
6565 // Never skip tests in CI. Toolchain should be up-to-date
6666 checkResult = . featureSupported
6767 } 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
7369 let requiredSwiftVersion = SwiftVersion ( swiftVersion. major, swiftVersion. minor)
7470 if toolchainSwiftVersion < requiredSwiftVersion {
7571 checkResult = . featureUnsupported(
@@ -174,10 +170,6 @@ public actor SkipUnless {
174170
175171 /// SwiftPM moved the location where it stores Swift modules to a subdirectory in
176172 /// 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.
181173 public static func swiftpmStoresModulesInSubdirectory(
182174 file: StaticString = #filePath,
183175 line: UInt = #line
@@ -297,60 +289,3 @@ fileprivate extension String {
297289 }
298290 }
299291}
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