Skip to content

Commit 439ea2f

Browse files
adonovangopherbot
authored andcommitted
gopls/internal/test/integration: fix race
Gotta install the message collector before we trigger the thing that causes the message to be sent! Fixes golang/go#74072 Change-Id: Ia110703ff0a7ad6b32939be9cd6615cef649e6bf Reviewed-on: https://go-review.googlesource.com/c/tools/+/680756 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Robert Findley <[email protected]> Auto-Submit: Alan Donovan <[email protected]>
1 parent 21c9b36 commit 439ea2f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

gopls/internal/test/integration/env.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ func (a *Awaiter) onShowMessage(_ context.Context, params *protocol.ShowMessageP
202202
// notifications. Call the resulting func to deregister the listener and
203203
// receive all notifications that have occurred since the listener was
204204
// registered.
205+
//
206+
// ListenToShownMessages should be called before the operation that
207+
// generates the showMessage event to ensure that the event is
208+
// reliably collected.
205209
func (a *Awaiter) ListenToShownMessages() func() []*protocol.ShowMessageParams {
206210
id := nextAwaiterRegistration.Add(1)
207211

gopls/internal/test/integration/misc/generate_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ var x = 1
119119
`
120120
Run(t, src, func(t *testing.T, env *Env) {
121121
env.OpenFile("a/a.go")
122-
env.RegexpReplace("a/a.go", "var", "const")
123122
collectMessages := env.Awaiter.ListenToShownMessages()
123+
env.RegexpReplace("a/a.go", "var", "const")
124124
env.Await(env.DoneWithChange())
125125
messages := collectMessages()
126126

0 commit comments

Comments
 (0)