1
0
Fork 0

Fix pipe deadlock in CLI generation lint test

This commit is contained in:
Brendan Szymanski 2026-07-01 14:46:45 -04:00
parent cacd83dfe4
commit 84a536d314

View file

@ -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)")
}