Fix pipe deadlock in CLI generation lint test
This commit is contained in:
parent
cacd83dfe4
commit
84a536d314
1 changed files with 6 additions and 1 deletions
|
|
@ -63,6 +63,7 @@ struct CLIGenerationLintTests {
|
|||
#expect(FileManager.default.fileExists(atPath: outputDir.appendingPathComponent("Package.swift").path))
|
||||
|
||||
// Phase 2: Lint the generated output with --strict
|
||||
let lintLog = URL(fileURLWithPath: "/tmp/swift-gtk-gen-lint-\(suffix).log")
|
||||
let lintProcess = Process()
|
||||
lintProcess.executableURL = URL(fileURLWithPath: "/usr/bin/swift")
|
||||
lintProcess.arguments = [
|
||||
|
|
@ -75,10 +76,14 @@ struct CLIGenerationLintTests {
|
|||
let lintPipe = Pipe()
|
||||
lintProcess.standardOutput = lintPipe
|
||||
lintProcess.standardError = lintPipe
|
||||
DispatchQueue.global().async {
|
||||
let data = lintPipe.fileHandleForReading.readDataToEndOfFile()
|
||||
try? data.write(to: lintLog)
|
||||
}
|
||||
try lintProcess.run()
|
||||
lintProcess.waitUntilExit()
|
||||
|
||||
let lintOutput = String(data: lintPipe.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) ?? ""
|
||||
let lintOutput = (try? String(contentsOf: lintLog, encoding: .utf8)) ?? ""
|
||||
if lintProcess.terminationStatus != 0 {
|
||||
Issue.record("Lint failed with exit \(lintProcess.terminationStatus):\n\(lintOutput)")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue