From 655abda1c0230800004a343281dfcf5615b432ce Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Thu, 1 Sep 2022 21:02:09 -0400 Subject: [PATCH] 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 Reviewed-by: Alan Donovan Run-TryBot: Robert Findley gopls-CI: kokoro --- .../internal/regtest/diagnostics/diagnostics_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gopls/internal/regtest/diagnostics/diagnostics_test.go b/gopls/internal/regtest/diagnostics/diagnostics_test.go index 4b38bf0e57..432b9b1e46 100644 --- a/gopls/internal/regtest/diagnostics/diagnostics_test.go +++ b/gopls/internal/regtest/diagnostics/diagnostics_test.go @@ -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"), + ), ) }) }