gopls/internal/regtest: TestEditGoDirectiveWorkspace should fail eagerly

TestEditGoDirectiveWorkspace did an unconditional wait on expected
diagnostics. Turn this into OnceMet conditions that fail as soon as the
relevant diagnostic pass is complete.

Fixes golang/go#54825

Change-Id: I2654682108561dd60546a589ebd1c6aa2ebaff1f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/427543
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Robert Findley 2022-09-01 21:02:09 -04:00
parent 33c1ddd5a8
commit 655abda1c0
1 changed files with 11 additions and 1 deletions

View File

@ -2141,17 +2141,27 @@ func F[T any](_ T) {
`
Run(t, files, func(_ *testing.T, env *Env) { // Create a new workspace-level directory and empty file.
var d protocol.PublishDiagnosticsParams
// Once the initial workspace load is complete, we should have a diagnostic
// because generics are not supported at 1.16.
env.Await(
OnceMet(
InitialWorkspaceLoad,
env.DiagnosticAtRegexpWithMessage("main.go", `T any`, "type parameter"),
ReadDiagnostics("main.go", &d),
),
)
// This diagnostic should have a quick fix to edit the go version.
env.ApplyQuickFixes("main.go", d.Diagnostics)
// Once the edit is applied, the problematic diagnostics should be
// resolved.
env.Await(
EmptyDiagnostics("main.go"),
OnceMet(
env.DoneWithChangeWatchedFiles(), // go.mod should have been quick-fixed
EmptyDiagnostics("main.go"),
),
)
})
}