mirror of https://github.com/golang/go.git
gopls/internal/regtest: test metadata validation only on save for go.mod
There was never a test that actually confirmed that golang/go#42529 was fixed, so it never actually was. Updates golang/go#42529 Change-Id: I4264162e98c5fde804c780e098a1d4e21a2d88d8 Reviewed-on: https://go-review.googlesource.com/c/tools/+/279033 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: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
5b43ef9348
commit
11a5667e27
|
|
@ -5,6 +5,7 @@
|
|||
package regtest
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
|
@ -770,3 +771,42 @@ func main() {
|
|||
)
|
||||
})
|
||||
}
|
||||
|
||||
// This test confirms that editing a go.mod file only causes metadata
|
||||
// to be invalidated when it's saved.
|
||||
func TestGoModInvalidatesOnSave(t *testing.T) {
|
||||
t.Skipf("golang/go#42529 has not been resolved yet.")
|
||||
|
||||
const mod = `
|
||||
-- go.mod --
|
||||
module mod.com
|
||||
|
||||
go 1.12
|
||||
-- main.go --
|
||||
package main
|
||||
|
||||
func main() {
|
||||
hello()
|
||||
}
|
||||
-- hello.go --
|
||||
package main
|
||||
|
||||
func hello() {}
|
||||
`
|
||||
run(t, mod, func(t *testing.T, env *Env) {
|
||||
env.OpenFile("go.mod")
|
||||
env.RegexpReplace("go.mod", "module", "modul")
|
||||
// Confirm that we still have metadata with only on-disk edits.
|
||||
env.OpenFile("main.go")
|
||||
file, _ := env.GoToDefinition("main.go", env.RegexpSearch("main.go", "hello"))
|
||||
if filepath.Base(file) != "hello.go" {
|
||||
t.Fatalf("expected definition in hello.go, got %s", file)
|
||||
}
|
||||
// Confirm that we no longer have metadata when the file is saved.
|
||||
env.Editor.SaveBufferWithoutActions(env.Ctx, "go.mod")
|
||||
_, _, err := env.Editor.GoToDefinition(env.Ctx, "main.go", env.RegexpSearch("main.go", "hello"))
|
||||
if err == nil {
|
||||
t.Fatalf("expected error, got none")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue