File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -214,9 +214,19 @@ final class MainFilesProviderTests: XCTestCase {
214214
215215 // 'MyFancyLibrary.c' now also includes 'shared.h'. Since it lexicographically preceeds MyLibrary, we should use its
216216 // build settings.
217- let postEditDiags = try await project. testClient. nextDiagnosticsNotification ( )
218- XCTAssertEqual ( postEditDiags. diagnostics. count, 1 )
219- let postEditDiag = try XCTUnwrap ( postEditDiags. diagnostics. first)
220- XCTAssertEqual ( postEditDiag. message, " Unused variable 'fromMyFancyLibrary' " )
217+ // `clangd` may return diagnostics from the old build settings sometimes (I believe when it's still building the
218+ // preamble for shared.h when the new build settings come in). Check that it eventually returns the correct
219+ // diagnostics.
220+ var receivedCorrectDiagnostic = false
221+ for _ in 0 ..< Int ( defaultTimeout) {
222+ let refreshedDiags = try await project. testClient. nextDiagnosticsNotification ( timeout: 1 )
223+ if let diagnostic = refreshedDiags. diagnostics. only,
224+ diagnostic. message == " Unused variable 'fromMyFancyLibrary' "
225+ {
226+ receivedCorrectDiagnostic = true
227+ break
228+ }
229+ }
230+ XCTAssert ( receivedCorrectDiagnostic)
221231 }
222232}
You can’t perform that action at this time.
0 commit comments