Skip to content

Commit 32f6057

Browse files
authored
Address more Wasm issues (#77)
* Fix SwiftWasm Glibc import issue SwiftWasm introduced its own WASI module awhile back, so we should import that instead of Glibc to avoid potential issues. * Fix WASI import * wip * fix * wip
1 parent b13b1d1 commit 32f6057

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,11 @@ jobs:
3232
wasm:
3333
name: Wasm
3434
runs-on: ubuntu-latest
35-
strategy:
36-
matrix:
37-
include:
38-
- { toolchain: wasm-5.7.1-RELEASE }
39-
4035
steps:
4136
- uses: actions/checkout@v4
42-
- run: echo "${{ matrix.toolchain }}" > .swift-version
43-
- uses: swiftwasm/[email protected]
37+
- uses: swiftwasm/[email protected]
4438
with:
45-
shell-action: swift build
39+
shell-action: carton test
4640

4741
windows:
4842
name: Windows

Sources/XCTestDynamicOverlay/XCTFail.swift

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,20 @@ public struct XCTFailContext: Sendable {
164164
}
165165
}
166166

167-
#if os(Windows)
167+
#if canImport(Glibc)
168+
import Glibc
169+
170+
private func ResolveXCTFail() -> XCTFailType? {
171+
var hXCTest = dlopen("libXCTest.so", RTLD_NOW)
172+
if hXCTest == nil { hXCTest = dlopen(nil, RTLD_NOW) }
173+
174+
if let pXCTFail = dlsym(hXCTest, "$s6XCTest7XCTFail_4file4lineySS_s12StaticStringVSutF") {
175+
return unsafeCastToXCTFailType(pXCTFail)
176+
}
177+
178+
return nil
179+
}
180+
#elseif canImport(WinSDK)
168181
import WinSDK
169182

170183
private func ResolveXCTFail() -> XCTFailType? {
@@ -180,22 +193,15 @@ public struct XCTFailContext: Sendable {
180193

181194
return nil
182195
}
183-
#else
184-
#if os(WASI)
185-
import WASI
186-
#else
187-
import Glibc
188-
#endif
196+
#elseif canImport(XCTest)
197+
import XCTest
189198

190199
private func ResolveXCTFail() -> XCTFailType? {
191-
var hXCTest = dlopen("libXCTest.so", RTLD_NOW)
192-
if hXCTest == nil { hXCTest = dlopen(nil, RTLD_NOW) }
193-
194-
if let pXCTFail = dlsym(hXCTest, "$s6XCTest7XCTFail_4file4lineySS_s12StaticStringVSutF") {
195-
return unsafeCastToXCTFailType(pXCTFail)
196-
}
197-
198-
return nil
200+
XCTFail
201+
}
202+
#else
203+
private func ResolveXCTFail() -> XCTFailType? {
204+
nil
199205
}
200206
#endif
201207

Tests/XCTestDynamicOverlayTests/GeneratePlaceholderTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !os(Linux) && !os(Windows)
1+
#if !os(Linux) && !os(WASI) && !os(Windows)
22
import Foundation
33
import XCTest
44
import XCTestDynamicOverlay

Tests/XCTestDynamicOverlayTests/UnimplementedTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !os(Linux) && !os(Windows)
1+
#if !os(Linux) && !os(WASI) && !os(Windows)
22
import XCTest
33

44
final class UnimplementedTests: XCTestCase {

Tests/XCTestDynamicOverlayTests/XCTContextTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !os(Linux) && !os(Windows)
1+
#if !os(Linux) && !os(WASI) && !os(Windows)
22
import XCTest
33
import XCTestDynamicOverlay
44

0 commit comments

Comments
 (0)