Skip to content

Commit 714e520

Browse files
authored
Merge pull request #1820 from ahoppen/wait-for-diags
2 parents 78f9968 + e303360 commit 714e520

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Tests/SourceKitLSPTests/PublishDiagnosticsTests.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,14 @@ final class PublishDiagnosticsTests: XCTestCase {
137137
)
138138

139139
_ = try project.openDocument("FileB.swift")
140-
let diagnosticsBeforeChangingFileA = try await project.testClient.nextDiagnosticsNotification()
141-
XCTAssert(
142-
diagnosticsBeforeChangingFileA.diagnostics.contains(where: { $0.message == "Cannot find 'sayHello' in scope" })
143-
)
140+
try await repeatUntilExpectedResult {
141+
let diagnostics = try await project.testClient.nextDiagnosticsNotification()
142+
if diagnostics.diagnostics.contains(where: { $0.message == "Cannot find 'sayHello' in scope" }) {
143+
return true
144+
}
145+
logger.debug("Received unexpected diagnostics: \(diagnostics.forLogging)")
146+
return false
147+
}
144148

145149
let updatedACode = "func sayHello() {}"
146150
let aUri = try project.uri(for: "FileA.swift")

0 commit comments

Comments
 (0)