Skip to content

Multi-thread pulling of out put from AsyncProcess #8549

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

Closed
wants to merge 11 commits into from
Closed
490 changes: 259 additions & 231 deletions Package.swift

Large diffs are not rendered by default.

1,136 changes: 689 additions & 447 deletions Sources/Basics/Concurrency/AsyncProcess.swift

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions Sources/Commands/SwiftTestCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,8 @@ final class ParallelTestRunner {

/// The queue containing list of tests to run (producer).
private let pendingTests = SynchronizedQueue<UnitTest?>()
private var remaining = Set<String>()
private var remainingLock = NSLock()

/// The queue containing tests which are finished running.
private let finishedTests = SynchronizedQueue<TestResult?>()
Expand Down Expand Up @@ -1147,6 +1149,7 @@ final class ParallelTestRunner {
// Enqueue all the tests.
for test in tests {
pendingTests.enqueue(test)
remaining.insert(test.specifier)
}
self.numTests = tests.count
self.numCurrentTest = 0
Expand Down Expand Up @@ -1193,6 +1196,15 @@ final class ParallelTestRunner {
if result == .failure {
self.ranSuccessfully = false
}
self.remainingLock.withLock {
self.remaining.remove(test.specifier)
if self.remaining.count < 10 {
print("Remaining:", self.remaining.count)
for test in self.remaining {
print(">", test)
}
}
}
self.finishedTests.enqueue(TestResult(
unitTest: test,
output: output,
Expand Down
Loading