Skip to content

Commit

Permalink
gopls: fix the reset_golden.sh script and regenerate golden files
Browse files Browse the repository at this point in the history
Update the reset_golden.sh script to run the ./test and ./internal/lsp
directories, following the deprecation of ./internal/lsp/cmd and
./internal/lsp/source tests. Also, fix it to generate golden data for
tests that only run at 1.17 and earlier.

Use the newly fixed script to sync the golden data.

For golang/go#54845

Change-Id: I2b42dac91cf1c7e2e8e25fd2aa8ab23c91e05c6c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/434635
Reviewed-by: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
  • Loading branch information
findleyr committed Sep 26, 2022
1 parent 49a686d commit c5cd943
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 49 deletions.
24 changes: 20 additions & 4 deletions gopls/internal/lsp/reset_golden.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,27 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
#
# Regenerates the *.golden files in the ./internal/lsp/testdata directory.
# Updates the *.golden files ... to match the tests' current behavior.

set -eu

GO117BIN="go1.17.9"

command -v $GO117BIN >/dev/null 2>&1 || {
go install golang.org/dl/$GO117BIN@latest
$GO117BIN download
}

find ./internal/lsp/testdata -name *.golden ! -name summary*.txt.golden -delete
go test ./internal/lsp/source -golden
go test ./internal/lsp/ -golden
go test ./internal/lsp/cmd -golden
# Here we intentionally do not run the ./internal/lsp/source tests with
# -golden. Eventually these tests will be deleted, and in the meantime they are
# redundant with the ./internal/lsp tests.
#
# Note: go1.17.9 tests must be run *before* go tests, as by convention the
# golden output should match the output of gopls built with the most recent
# version of Go. If output differs at 1.17, tests must be tolerant of the 1.17
# output.
$GO117BIN test ./internal/lsp -golden
go test ./internal/lsp -golden
$GO117BIN test ./test -golden
go test ./test -golden
50 changes: 25 additions & 25 deletions gopls/internal/lsp/testdata/godef/a/a.go.golden
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
-- H-hoverdef --
```go
type H interface {
Goodbye() //@mark(AGoodbye, "Goodbye")
}
```

[`a.H` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#H)
-- I-hoverdef --
```go
type I interface {
B() //@mark(AB, "B")
J
}
```

[`a.I` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#I)
-- J-hoverdef --
```go
type J interface {
Hello() //@mark(AHello, "Hello")
}
```

[`a.J` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#J)
-- Lock-hoverdef --
```go
func (*sync.Mutex).Lock()
Expand Down Expand Up @@ -165,31 +190,6 @@ const h untyped int = 2

Constant block.

-- H-hoverdef --
```go
type H interface {
Goodbye() //@mark(AGoodbye, "Goodbye")
}
```

[`a.H` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#H)
-- I-hoverdef --
```go
type I interface {
B() //@mark(AB, "B")
J
}
```

[`a.I` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#I)
-- J-hoverdef --
```go
type J interface {
Hello() //@mark(AHello, "Hello")
}
```

[`a.J` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#J)
-- make-hoverdef --
```go
func make(t Type, size ...int) Type
Expand Down
24 changes: 12 additions & 12 deletions gopls/internal/lsp/testdata/godef/a/d.go.golden
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ func (Thing).Method(i int) string
```

[`(a.Thing).Method` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Thing.Method)
-- NextThing-hoverdef --
```go
type NextThing struct {
Thing
Value int
}

func (*NextThing).Method3() int
func (NextThing).another() string
```

[`a.NextThing` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#NextThing)
-- Other-definition --
godef/a/d.go:9:5-10: defined here as ```go
var Other Thing
Expand Down Expand Up @@ -177,15 +189,3 @@ func Things(val []string) []Thing
-- a-hoverdef --
Package a is a package for testing go to definition.

-- NextThing-hoverdef --
```go
type NextThing struct {
Thing
Value int
}

func (*NextThing).Method3() int
func (NextThing).another() string
```

[`a.NextThing` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#NextThing)
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
-- Pparam-hoverdef --
```go
type parameter P interface{~int|string}
```
-- Pvar-hoverdef --
```go
type parameter P interface{~int|string}
```
-- ValueQfield-hoverdef --
```go
field Q int
Expand Down

0 comments on commit c5cd943

Please sign in to comment.