Skip to content

Commit 32cec11

Browse files
findleyrgopherbot
authored andcommitted
gopls/internal/test/integration: fix race in TestGCDetails_Toggle
The AfterChange predicate is insufficient for awaiting the GC details command. We must await the specific diagnosis of GC details. Fix the predicate, and update the documentation for AfterChange to more clearly spell out what it awaits. Fixes golang/go#67428 Change-Id: I4923a4dac773f2c953a21bf026cadca4b9370ef3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/586878 Reviewed-by: Alan Donovan <[email protected]> Auto-Submit: Robert Findley <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent c3aae99 commit 32cec11

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

gopls/internal/test/integration/codelens/gcdetails_test.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,14 @@ func main() {
4949
env.OpenFile("main.go")
5050
env.ExecuteCodeLensCommand("main.go", command.GCDetails, nil)
5151

52-
env.AfterChange(Diagnostics(
53-
ForFile("main.go"),
54-
WithMessage("42 escapes"),
55-
WithSeverityTags("optimizer details", protocol.SeverityInformation, nil),
56-
))
52+
env.OnceMet(
53+
CompletedWork(server.DiagnosticWorkTitle(server.FromToggleGCDetails), 1, true),
54+
Diagnostics(
55+
ForFile("main.go"),
56+
WithMessage("42 escapes"),
57+
WithSeverityTags("optimizer details", protocol.SeverityInformation, nil),
58+
),
59+
)
5760

5861
// GCDetails diagnostics should be reported even on unsaved
5962
// edited buffers, thanks to the magic of overlays.

gopls/internal/test/integration/expectation.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,14 @@ func (e *Env) DoneDiagnosingChanges() Expectation {
342342

343343
// AfterChange expects that the given expectations will be met after all
344344
// state-changing notifications have been processed by the server.
345-
//
346-
// It awaits the completion of all anticipated work before checking the given
347-
// expectations.
345+
// Specifically, it awaits the awaits completion of the process of diagnosis
346+
// after the following notifications, before checking the given expectations:
347+
// - textDocument/didOpen
348+
// - textDocument/didChange
349+
// - textDocument/didSave
350+
// - textDocument/didClose
351+
// - workspace/didChangeWatchedFiles
352+
// - workspace/didChangeConfiguration
348353
func (e *Env) AfterChange(expectations ...Expectation) {
349354
e.T.Helper()
350355
e.OnceMet(

0 commit comments

Comments
 (0)