Repository navigation
test: wait for the pending diagnostics refresh, not the stored diagnostics - #1732
Merged
angelozerr merged 1 commit intoOct 20, 2026
Merged
angelozerr merged 1 commit into
angelozerr merged 1 commit into
Conversation
…stics testDiagnosticsPublishedBeforeThePassIsRegisteredAreShown (redhat-developer#1721) failed twice on main on macOS with "expected:<[published early]> but was:<[]>". OpenedDocument.updateDiagnostics stores the diagnostics and only then requests their refresh. The test waited for the stored diagnostics, so it could register the pass factory before the refresh was requested: nothing was pending, and the refresh came afterwards as an ordinary background one, after the test's single event dispatch. LSPDiagnosticsApplier.hasPendingRefreshes() (@testonly) says whether a refresh waits for GROUP_ID. The test waits for it before registering the pass factory, so it always checks the case it is about, and afterwards waits until the diagnostics are shown. No production behavior changes. Validation, with OpenedDocument.updateDiagnostics locally made to sleep a second between storing the diagnostics and requesting their refresh: the test on main fails as on CI, and the changed test passes; both pass without the delay. With redhat-developer#1721's fix reverted, the changed test fails ("the refresh must wait for the pass"). ./gradlew check: 595 tests, 0 failures, the 3 existing skips.
Contributor
|
LGTM, thanks @lagergren ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LSPDiagnosticsApplierTest.testDiagnosticsPublishedBeforeThePassIsRegisteredAreShown, added by #1721, failed twice onmain, both times on macOS only, withexpected:<[published early]> but was:<[]>:The test was wrong, not #1721's fix.
Problem
OpenedDocument.updateDiagnosticsstores the diagnostics (diagnosticsForServer.update(...)) and only then callsLSPDiagnosticsApplier.scheduleRefresh(...), on the thread that receivedpublishDiagnostics. The test waited until the opened document had diagnostics, which can be between the two. If it then registered the pass factory beforescheduleRefreshran, nothing was pending: the refresh came afterwards withGROUP_IDset and was applied as any other, in the background. The test dispatched the events once and asserted before that refresh had finished.Change
LSPDiagnosticsApplier.hasPendingRefreshes(), package-private and@TestOnly, says whether a refresh waits forGROUP_ID.No production behavior changes.
Validation
To widen the window,
OpenedDocument.updateDiagnosticswas made to sleep for a second between storing the diagnostics and requesting their refresh (locally only, not part of this change):mainexpected:<[published early]> but was:<[]>, as on CIWith #1721's fix reverted (the early refresh dropped), the changed test still fails: "the refresh must wait for the pass".
./gradlew check: 595 tests, 0 failures, the 3 existing skips.