1
0
mirror of https://github.com/golang/go synced 2024-10-01 12:48:33 -06:00
go/internal/lsp/regtest
Rob Findley 1d9c21a7db internal/lsp/regtest: add support for testing generate commands
Our editor interaction for running `go generate` was untested. Add
support for triggering generate from the fake editor, and a simple test.

To enable this, some helpers were added to list Workspace files and
check for file state changes, to avoid having to synthetically create
file events. This workaround is not ideal as it results in a leaky
abstraction: in other cases the regtest may assume that FileEvents are
triggered by workspace interactions (e.g. ws.WriteFile), but in this
case it cannot. Unfortunately the only real solution for this would be
to make file watching more realistic, by polling file state on an
interval or using an actual file watching library. Neither of those
options seemed worthwhile just to keep the fake.Editor API pristine.

A new debugging option is added, SkipCleanup, to allow inspecting
regtest working directories after a test with minimal code change.

Change-Id: I64dceeb21a4eb9eff2b6936e44f80f4bd24b82da
Reviewed-on: https://go-review.googlesource.com/c/tools/+/230313
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-05-04 19:25:30 +00:00
..
definition_test.go internal/lsp/regtest: put testing.T back in the test func signature 2020-04-14 18:42:46 +00:00
diagnostics_114_test.go internal/lsp/regtest: add regtest for golang/go#38207 2020-04-22 01:51:11 +00:00
diagnostics_test.go internal/lsp: avoid showing no-GOPATH-nor-module message so much 2020-05-02 20:28:11 +00:00
doc.go internal/lsp/regtest: add expository package documentation 2020-04-28 21:10:48 +00:00
env_test.go internal/lsp: instrument work done reporting to use in regtests 2020-04-28 20:46:32 +00:00
env.go internal/lsp: avoid showing no-GOPATH-nor-module message so much 2020-05-02 20:28:11 +00:00
formatting_test.go internal/lsp: add a regtest for formatting one-line files 2020-05-01 15:50:19 +00:00
generate_test.go internal/lsp/regtest: add support for testing generate commands 2020-05-04 19:25:30 +00:00
reg_test.go internal/lsp/regtest: generalize expectations beyond diagnostic messages 2020-04-16 21:39:01 +00:00
runner.go internal/lsp/regtest: add support for testing generate commands 2020-05-04 19:25:30 +00:00
serialization_test.go internal/lsp/regtest: put testing.T back in the test func signature 2020-04-14 18:42:46 +00:00
shared_test.go internal/lsp/regtest: rename and document some symbols 2020-04-28 21:10:38 +00:00
wrappers.go internal/lsp/regtest: add support for testing generate commands 2020-05-04 19:25:30 +00:00