1
0
mirror of https://github.com/golang/go synced 2024-10-01 01:08:33 -06:00
go/internal/lsp/regtest
Rob Findley 8f5be0d382 internal/lsp/regtest: add functions to make diagnostic assertions easier
One of the tricky things about asserting on conditions in regtests is
the asynchronous nature of LSP. For example, as the LSP client we cannot
be sure when we've received all diagnostics for a given file.

Currently, regtests are implemented by awaiting specific diagnostic
expectations.  This means that if gopls generates diagnostics that do
not match those expectations, we can only time out the test.

Ideally, we would want to know that gopls is done generating all diagnostics
for the current file state. This is not possible without knowing the
status of diagnostics for. Barring this, we would want to know that
diagnostics are done for the current file version. Unfortunately, that
also is not possible, because a new version of file B can affect
diagnostics in file A.

So in lieu of this information, this CL exposes a few tools that can be
used to improve the experience of writing new regtests.

 - A new expectation is added: AnyDiagnosticAtCurrentVersion, that is
   satisfied if any diagnostics have been received for the current
   buffer version.
 - ExpectDiagnostics is added to Env, to help check whether the current
   diagnostics matches expectations.

Updates golang/go#38113

Change-Id: I48d2c3db87c13ac3ab424d01d9444cbc285af9e1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/226842
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-04-02 20:10:23 +00:00
..
definition_test.go internal/lsp/regtest: remove redundant T and ctx params from regtest funcs 2020-03-24 20:18:24 +00:00
diagnostics_test.go internal/lsp/regtest: add functions to make diagnostic assertions easier 2020-04-02 20:10:23 +00:00
env.go internal/lsp/regtest: add functions to make diagnostic assertions easier 2020-04-02 20:10:23 +00:00
formatting_test.go internal/lsp/regtest: remove redundant T and ctx params from regtest funcs 2020-03-24 20:18:24 +00:00
reg_test.go internal/lsp/regtest: clean-up and more error handling 2020-02-25 19:00:36 +00:00
serialization_test.go internal/lsp/regtest: remove redundant T and ctx params from regtest funcs 2020-03-24 20:18:24 +00:00
shared_test.go internal/lsp/regtest: remove redundant T and ctx params from regtest funcs 2020-03-24 20:18:24 +00:00
wrappers.go internal/lsp: remove command-line-arguments as a workspace package 2020-03-25 20:31:30 +00:00