gopls/internal/regtests: add a test for bad go.work files

Add a test that would have reproduced the panic from
golang/vscode-go#2121.

For golang/vscode-go#2121

Change-Id: Idb07dc0789b51e3056e0b3d0910916ec35931ac4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/397355
Run-TryBot: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Robert Findley 2022-03-31 15:38:16 -04:00 committed by Gopher Robot
parent f97a804487
commit 44db4ebc77
1 changed files with 13 additions and 0 deletions

View File

@ -644,6 +644,19 @@ replace a.com => %s/moda/a
})
}
// TestBadGoWork exercises the panic from golang/vscode-go#2121.
func TestBadGoWork(t *testing.T) {
const files = `
-- go.work --
use ./bar
-- bar/go.mod --
module example.com/bar
`
Run(t, files, func(t *testing.T, env *Env) {
env.OpenFile("go.work")
})
}
func TestUseGoWork(t *testing.T) {
// This test validates certain functionality related to using a go.work
// file to specify workspace modules.