gopls/internal/regtest: add a test for switching from modules to GOPATH

Fixes golang/go#40487

Change-Id: I79457a8de559da2a9a3ffabdb315f4d35345c8a0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/261738
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
Rebecca Stambler 2020-10-13 01:13:42 -04:00
Родитель d88ec18c69
Коммит 0112737ef1
1 изменённых файлов: 40 добавлений и 0 удалений

Просмотреть файл

@ -622,6 +622,46 @@ func main() {
}) })
} }
// Reproduces golang/go#40487.
func TestSwitchFromModulesToGOPATH(t *testing.T) {
testenv.NeedsGo1Point(t, 13)
const files = `
-- foo/go.mod --
module mod.com
go 1.14
-- foo/blah/blah.go --
package blah
const Name = ""
-- foo/main.go --
package main
import "mod.com/blah"
func main() {
_ = blah.Name
}
`
withOptions(
InGOPATH(),
).run(t, files, func(t *testing.T, env *Env) {
env.OpenFile("foo/main.go")
env.RemoveWorkspaceFile("foo/go.mod")
env.Await(
OnceMet(
CompletedWork(lsp.DiagnosticWorkTitle(lsp.FromDidChangeWatchedFiles), 1),
env.DiagnosticAtRegexp("foo/main.go", `"mod.com/blah"`),
),
)
env.RegexpReplace("foo/main.go", `"mod.com/blah"`, `"foo/blah"`)
env.Await(
EmptyDiagnostics("foo/main.go"),
)
})
}
func TestNewSymbolInTestVariant(t *testing.T) { func TestNewSymbolInTestVariant(t *testing.T) {
const files = ` const files = `
-- go.mod -- -- go.mod --