Skip to content

Commit 7e1c6b9

Browse files
authored
Use readData to read data from a pipe instead of availableData (#8047)
Using `availableData` causes parallel XCTest execution to hang on Windows if the tests output significant data to stderr.
1 parent d28f725 commit 7e1c6b9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/Basics/Concurrency/AsyncProcess.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ package final class AsyncProcess {
501501

502502
group.enter()
503503
stdoutPipe.fileHandleForReading.readabilityHandler = { (fh: FileHandle) in
504-
let data = fh.availableData
504+
let data = (try? fh.read(upToCount: Int.max)) ?? Data()
505505
if data.count == 0 {
506506
stdoutPipe.fileHandleForReading.readabilityHandler = nil
507507
group.leave()
@@ -516,7 +516,7 @@ package final class AsyncProcess {
516516

517517
group.enter()
518518
stderrPipe.fileHandleForReading.readabilityHandler = { (fh: FileHandle) in
519-
let data = fh.availableData
519+
let data = (try? fh.read(upToCount: Int.max)) ?? Data()
520520
if data.count == 0 {
521521
stderrPipe.fileHandleForReading.readabilityHandler = nil
522522
group.leave()

0 commit comments

Comments
 (0)