Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.10] Fix test runner build on WASI #7351

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Sources/Build/TestObservation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ public func generateTestObservationCode(buildParameters: BuildParameters) -> Str
#elseif os(Windows)
@_exported import CRT
@_exported import WinSDK
#elseif os(WASI)
@_exported import WASILibc
#else
@_exported import Darwin.C
#endif
Expand Down Expand Up @@ -176,6 +178,8 @@ public func generateTestObservationCode(buildParameters: BuildParameters) -> Str
UInt32.max, UInt32.max, &overlapped) {
throw ProcessLockError.unableToAquireLock(errno: Int32(GetLastError()))
}
#elseif os(WASI)
// WASI doesn't support flock
#else
if fileDescriptor == nil {
let fd = open(lockFile.path, O_WRONLY | O_CREAT | O_CLOEXEC, 0o666)
Expand All @@ -201,6 +205,8 @@ public func generateTestObservationCode(buildParameters: BuildParameters) -> Str
overlapped.OffsetHigh = 0
overlapped.hEvent = nil
UnlockFileEx(handle, 0, UInt32.max, UInt32.max, &overlapped)
#elseif os(WASI)
// WASI doesn't support flock
#else
guard let fd = fileDescriptor else { return }
flock(fd, LOCK_UN)
Expand All @@ -211,6 +217,8 @@ public func generateTestObservationCode(buildParameters: BuildParameters) -> Str
#if os(Windows)
guard let handle = handle else { return }
CloseHandle(handle)
#elseif os(WASI)
// WASI doesn't support flock
#else
guard let fd = fileDescriptor else { return }
close(fd)
Expand Down