Skip to content

Commit 48c64b2

Browse files
committed
Add logs around various exits
1 parent 69a7a93 commit 48c64b2

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Sources/swift-driver/main.swift

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,30 +155,49 @@ do {
155155
// FIXME: The following check should be at the end of Driver.init, but current
156156
// usage of the DiagnosticVerifier in tests makes this difficult.
157157
guard !driver.diagnosticEngine.hasErrors else {
158+
printToStderr("DRIVER EXTRA VERBOSE HAD ERRORS")
158159
throw Driver.ErrorDiagnostics.emitted
159160
}
160161

162+
printToStderr("DRIVER EXTRA VERBOSE STARTING PLANNING")
161163
let jobs = try driver.planBuild()
164+
printToStderr("DRIVER EXTRA VERBOSE FINISHED PLANNING")
162165

163166
// Planning may result in further errors emitted
164167
// due to dependency scanning failures.
165168
guard !driver.diagnosticEngine.hasErrors else {
169+
printToStderr("DRIVER EXTRA VERBOSE HAD ERRORS")
166170
throw Driver.ErrorDiagnostics.emitted
167171
}
168172

173+
printToStderr("DRIVER EXTRA VERBOSE RUNNING JOBS")
169174
try driver.run(jobs: jobs)
175+
printToStderr("DRIVER EXTRA VERBOSE FINISHED JOBS")
170176

171177
if driver.diagnosticEngine.hasErrors {
178+
printToStderr("DRIVER EXTRA VERBOSE HAD ERRORS")
172179
exit(getExitCode(EXIT_FAILURE))
173180
}
174181

182+
printToStderr("DRIVER EXTRA VERBOSE SUCCESS")
175183
exit(getExitCode(0))
176184
} catch let diagnosticData as DiagnosticData {
185+
printToStderr("DRIVER EXTRA VERBOSE IN CATCH FOR DIAGNOSTIC EMISSION")
177186
diagnosticsEngine.emit(.error(diagnosticData))
178187
exit(getExitCode(EXIT_FAILURE))
179188
} catch Driver.ErrorDiagnostics.emitted {
189+
printToStderr("DRIVER EXTRA VERBOSE IN CATCH FOR ALREADY EMITTED DIAGNOSTICS")
180190
exit(getExitCode(EXIT_FAILURE))
181191
} catch {
182-
print("error: \(error)")
192+
printToStderr("DRIVER EXTRA VERBOSE IN CATCH FOR OTHER ERROR")
193+
printToStderr("error: \(error)")
183194
exit(getExitCode(EXIT_FAILURE))
184195
}
196+
197+
import var TSCBasic.stderrStream
198+
func printToStderr(_ message: String) {
199+
Driver.stdErrQueue.sync {
200+
stderrStream.send(message + "\n")
201+
stderrStream.flush()
202+
}
203+
}

0 commit comments

Comments
 (0)