Skip to content

Commit fc1043e

Browse files
authored
StdlibUnittest: fix building with WASI (#67394)
This file can now be built for WASI when `WASILibc` is imported. Only slight branching is needed to disable child process spawning for this platform.
1 parent 972af58 commit fc1043e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

stdlib/private/StdlibUnittest/StdlibUnittest.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import Darwin
2424
import Glibc
2525
#elseif canImport(Musl)
2626
import Musl
27+
#elseif os(WASI)
28+
import WASILibc
2729
#elseif os(Windows)
2830
import CRT
2931
import WinSDK
@@ -37,6 +39,12 @@ import ObjectiveC
3739
import _Concurrency
3840
#endif
3941

42+
#if os(WASI)
43+
let platformSupportsChildProcesses = false
44+
#else
45+
let platformSupportsChildProcesses = true
46+
#endif
47+
4048
extension String {
4149
/// Returns the lines in `self`.
4250
public var _lines : [String] {
@@ -1726,7 +1734,7 @@ public func runAllTests() {
17261734
if _isChildProcess {
17271735
_childProcess()
17281736
} else {
1729-
var runTestsInProcess: Bool = false
1737+
var runTestsInProcess: Bool = !platformSupportsChildProcesses
17301738
var filter: String?
17311739
var args = [String]()
17321740
var i = 0
@@ -1796,7 +1804,7 @@ public func runAllTestsAsync() async {
17961804
if _isChildProcess {
17971805
await _childProcessAsync()
17981806
} else {
1799-
var runTestsInProcess: Bool = false
1807+
var runTestsInProcess: Bool = !platformSupportsChildProcesses
18001808
var filter: String?
18011809
var args = [String]()
18021810
var i = 0

0 commit comments

Comments
 (0)