Skip to content

Commit 6b494dd

Browse files
committed
Flush logs at the end of test execution
Otherwise it sometimes happens that shutdown and other messages are logged during the next test’s execution, which makes it harder to diagnose issues.
1 parent cfe3ea9 commit 6b494dd

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Sources/SKTestSupport/TestSourceKitLSPClient.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import InProcessClient
1515
package import LanguageServerProtocol
1616
import LanguageServerProtocolExtensions
1717
import LanguageServerProtocolJSONRPC
18+
import SKLogging
1819
package import SKOptions
1920
import SKUtilities
2021
import SourceKitD
@@ -217,14 +218,21 @@ package final class TestSourceKitLSPClient: MessageHandler, Sendable {
217218
deinit {
218219
// It's really unfortunate that there are no async deinits. If we had async
219220
// deinits, we could await the sending of a ShutdownRequest.
220-
let sema = WrappedSemaphore(name: "Shutdown")
221+
let shutdownSemaphore = WrappedSemaphore(name: "Shutdown")
221222
server.handle(ShutdownRequest(), id: .number(Int(nextRequestID.fetchAndIncrement()))) { result in
222-
sema.signal()
223+
shutdownSemaphore.signal()
223224
}
224-
sema.waitOrXCTFail()
225+
shutdownSemaphore.waitOrXCTFail()
225226
self.send(ExitNotification())
226227

227228
cleanUp()
229+
230+
let flushSemaphore = WrappedSemaphore(name: "Flush log")
231+
Task {
232+
await NonDarwinLogger.flush()
233+
flushSemaphore.signal()
234+
}
235+
flushSemaphore.waitOrXCTFail()
228236
}
229237

230238
// MARK: - Sending messages

0 commit comments

Comments
 (0)