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))
|
#expect(FileManager.default.fileExists(atPath: outputDir.appendingPathComponent("Package.swift").path))
|
||||||
|
|
||||||
// Phase 2: Lint the generated output with --strict
|
// Phase 2: Lint the generated output with --strict
|
||||||
|
let lintLog = URL(fileURLWithPath: "/tmp/swift-gtk-gen-lint-\(suffix).log")
|
||||||
let lintProcess = Process()
|
let lintProcess = Process()
|
||||||
lintProcess.executableURL = URL(fileURLWithPath: "/usr/bin/swift")
|
lintProcess.executableURL = URL(fileURLWithPath: "/usr/bin/swift")
|
||||||
lintProcess.arguments = [
|
lintProcess.arguments = [
|
||||||
|
|
@ -75,10 +76,14 @@ struct CLIGenerationLintTests {
|
||||||
let lintPipe = Pipe()
|
let lintPipe = Pipe()
|
||||||
lintProcess.standardOutput = lintPipe
|
lintProcess.standardOutput = lintPipe
|
||||||
lintProcess.standardError = lintPipe
|
lintProcess.standardError = lintPipe
|
||||||
|
DispatchQueue.global().async {
|
||||||
|
let data = lintPipe.fileHandleForReading.readDataToEndOfFile()
|
||||||
|
try? data.write(to: lintLog)
|
||||||
|
}
|
||||||
try lintProcess.run()
|
try lintProcess.run()
|
||||||
lintProcess.waitUntilExit()
|
lintProcess.waitUntilExit()
|
||||||
|
|
||||||
let lintOutput = String(data: lintPipe.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) ?? ""
|
let lintOutput = (try? String(contentsOf: lintLog, encoding: .utf8)) ?? ""
|
||||||
if lintProcess.terminationStatus != 0 {
|
if lintProcess.terminationStatus != 0 {
|
||||||
Issue.record("Lint failed with exit \(lintProcess.terminationStatus):\n\(lintOutput)")
|
Issue.record("Lint failed with exit \(lintProcess.terminationStatus):\n\(lintOutput)")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue