Skip to content

Commit 5236e7a

Browse files
committed
Fix remaining Windows test issues
testPlatformOptionsCreateNewConsole: this test was meaning to assert that the values are different, not that they're the same. Fix this simple logic issue. testRunDetached: this test never completed reading the output, because the write fd was kept open and reading never completed. Close the write fd before reading. testInputSequenceCustomExecutionBody, testInputAsyncSequenceCustomExecutionBody, testRedirectedOutputRedirectToSequence: these tests hit an implementation issue where EOF was not correctly detected, leading to a hang. Change the logic to return nil if an empty buffer is received. This patch also enables CI tests for Windows.
1 parent c31f191 commit 5236e7a

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

.github/workflows/pull_request.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ jobs:
2424
dnf install -y procps
2525
fi
2626
windows_swift_versions: '["6.1", "nightly-main"]'
27-
windows_build_command: 'swift build'
2827
enable_macos_checks: true
2928
macos_xcode_versions: '["16.3"]'
3029

Sources/Subprocess/Platforms/Subprocess+Windows.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ extension FileDescriptor {
10141014
case .failure(let error):
10151015
continuation.resume(throwing: error)
10161016
case .success(let bytes):
1017-
continuation.resume(returning: bytes)
1017+
continuation.resume(returning: bytes.isEmpty ? nil : bytes)
10181018
}
10191019
}
10201020
}

Tests/SubprocessTests/SubprocessTests+Windows.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ extension SubprocessWindowsTests {
528528
).trimmingCharacters(in: .whitespacesAndNewlines)
529529
// Make sure the child console is different from parent
530530
#expect(
531-
"\(intptr_t(bitPattern: parentConsole))" == differentConsoleValue
531+
"\(intptr_t(bitPattern: parentConsole))" != differentConsoleValue
532532
)
533533
}
534534

@@ -707,13 +707,13 @@ extension SubprocessWindowsTests {
707707
WaitForSingleObject(processHandle, INFINITE)
708708

709709
// Up to 10 characters because Windows process IDs are DWORDs (UInt32), whose max value is 10 digits.
710+
try writeFd.close()
710711
let data = try await readFd.readUntilEOF(upToLength: 10)
711712
let resultPID = try #require(
712713
String(data: data, encoding: .utf8)
713714
).trimmingCharacters(in: .whitespacesAndNewlines)
714715
#expect("\(pid.value)" == resultPID)
715716
try readFd.close()
716-
try writeFd.close()
717717
}
718718
}
719719

0 commit comments

Comments
 (0)