gopls/internal/regtest: handle flake in TestCRLF
Make the test a little more stable by making sure diagnostics complete
before organizing imports in these tests.
Change-Id: Id23341569207878554902887498632d6f1ce56cf
Reviewed-on: https://go-review.googlesource.com/c/tools/+/271628
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
diff --git a/gopls/internal/regtest/formatting_test.go b/gopls/internal/regtest/formatting_test.go
index 1f78d92..80344c1 100644
--- a/gopls/internal/regtest/formatting_test.go
+++ b/gopls/internal/regtest/formatting_test.go
@@ -4,6 +4,7 @@
"strings"
"testing"
+ "golang.org/x/tools/internal/lsp"
"golang.org/x/tools/internal/lsp/tests"
)
@@ -174,6 +175,7 @@
`
crlf := strings.ReplaceAll(want, "\n", "\r\n")
env.CreateBuffer("main.go", crlf)
+ env.Await(CompletedWork(lsp.DiagnosticWorkTitle(lsp.FromDidOpen), 1))
env.SaveBuffer("main.go")
got := env.Editor.BufferText("main.go")
if want != got {
@@ -212,6 +214,7 @@
`
crlf := strings.ReplaceAll(want, "\n", "\r\n")
env.CreateBuffer("main.go", crlf)
+ env.Await(CompletedWork(lsp.DiagnosticWorkTitle(lsp.FromDidOpen), 1))
env.OrganizeImports("main.go")
got := env.Editor.BufferText("main.go")
got = strings.ReplaceAll(got, "\r\n", "\n") // convert everything to LF for simplicity