Skip to content

Commit 91c87b6

Browse files
committed
Skip testWasm if the host toolchain can’t build for WASM
This fixes a test failure when running tests using Xcode 15.4.
1 parent c6b82a7 commit 91c87b6

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Sources/SKTestSupport/SkipUnless.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,24 @@ public actor SkipUnless {
462462
}
463463
}
464464
}
465+
466+
public static func canCompileForWasm(
467+
file: StaticString = #filePath,
468+
line: UInt = #line
469+
) async throws {
470+
return try await shared.skipUnlessSupportedByToolchain(swiftVersion: SwiftVersion(6, 0), file: file, line: line) {
471+
let swiftFrontend = try await unwrap(ToolchainRegistry.forTesting.default?.swift).parentDirectory
472+
.appending(component: "swift-frontend")
473+
return try await withTestScratchDir { scratchDirectory in
474+
let input = scratchDirectory.appending(component: "Input.swift")
475+
FileManager.default.createFile(atPath: input.pathString, contents: nil)
476+
let process = Process(args: swiftFrontend.pathString, "--version")
477+
try process.launch()
478+
let result = try await process.waitUntilExit()
479+
return result.exitStatus == .terminated(code: 0)
480+
}
481+
}
482+
}
465483
}
466484

467485
// MARK: - Parsing Swift compiler version

Tests/SourceKitLSPTests/SwiftPMIntegration.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ final class SwiftPMIntegrationTests: XCTestCase {
243243
}
244244

245245
func testWasm() async throws {
246+
try await SkipUnless.canCompileForWasm()
247+
246248
let project = try await SwiftPMTestProject(
247249
files: [
248250
"/.sourcekit-lsp/config.json": """

0 commit comments

Comments
 (0)