Skip to content

Commit c5cd943

Browse files
committed
gopls: fix the reset_golden.sh script and regenerate golden files
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 <[email protected]> gopls-CI: kokoro <[email protected]> Run-TryBot: Robert Findley <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 49a686d commit c5cd943

File tree

4 files changed

+57
-49
lines changed

4 files changed

+57
-49
lines changed

gopls/internal/lsp/reset_golden.sh

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,27 @@
44
# Use of this source code is governed by a BSD-style
55
# license that can be found in the LICENSE file.
66
#
7-
# Regenerates the *.golden files in the ./internal/lsp/testdata directory.
7+
# Updates the *.golden files ... to match the tests' current behavior.
88

99
set -eu
1010

11+
GO117BIN="go1.17.9"
12+
13+
command -v $GO117BIN >/dev/null 2>&1 || {
14+
go install golang.org/dl/$GO117BIN@latest
15+
$GO117BIN download
16+
}
17+
1118
find ./internal/lsp/testdata -name *.golden ! -name summary*.txt.golden -delete
12-
go test ./internal/lsp/source -golden
13-
go test ./internal/lsp/ -golden
14-
go test ./internal/lsp/cmd -golden
19+
# Here we intentionally do not run the ./internal/lsp/source tests with
20+
# -golden. Eventually these tests will be deleted, and in the meantime they are
21+
# redundant with the ./internal/lsp tests.
22+
#
23+
# Note: go1.17.9 tests must be run *before* go tests, as by convention the
24+
# golden output should match the output of gopls built with the most recent
25+
# version of Go. If output differs at 1.17, tests must be tolerant of the 1.17
26+
# output.
27+
$GO117BIN test ./internal/lsp -golden
28+
go test ./internal/lsp -golden
29+
$GO117BIN test ./test -golden
30+
go test ./test -golden

gopls/internal/lsp/testdata/godef/a/a.go.golden

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
-- H-hoverdef --
2+
```go
3+
type H interface {
4+
Goodbye() //@mark(AGoodbye, "Goodbye")
5+
}
6+
```
7+
8+
[`a.H` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#H)
9+
-- I-hoverdef --
10+
```go
11+
type I interface {
12+
B() //@mark(AB, "B")
13+
J
14+
}
15+
```
16+
17+
[`a.I` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#I)
18+
-- J-hoverdef --
19+
```go
20+
type J interface {
21+
Hello() //@mark(AHello, "Hello")
22+
}
23+
```
24+
25+
[`a.J` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#J)
126
-- Lock-hoverdef --
227
```go
328
func (*sync.Mutex).Lock()
@@ -165,31 +190,6 @@ const h untyped int = 2
165190

166191
Constant block.
167192

168-
-- H-hoverdef --
169-
```go
170-
type H interface {
171-
Goodbye() //@mark(AGoodbye, "Goodbye")
172-
}
173-
```
174-
175-
[`a.H` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#H)
176-
-- I-hoverdef --
177-
```go
178-
type I interface {
179-
B() //@mark(AB, "B")
180-
J
181-
}
182-
```
183-
184-
[`a.I` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#I)
185-
-- J-hoverdef --
186-
```go
187-
type J interface {
188-
Hello() //@mark(AHello, "Hello")
189-
}
190-
```
191-
192-
[`a.J` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#J)
193193
-- make-hoverdef --
194194
```go
195195
func make(t Type, size ...int) Type

gopls/internal/lsp/testdata/godef/a/d.go.golden

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ func (Thing).Method(i int) string
6464
```
6565

6666
[`(a.Thing).Method` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Thing.Method)
67+
-- NextThing-hoverdef --
68+
```go
69+
type NextThing struct {
70+
Thing
71+
Value int
72+
}
73+
74+
func (*NextThing).Method3() int
75+
func (NextThing).another() string
76+
```
77+
78+
[`a.NextThing` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#NextThing)
6779
-- Other-definition --
6880
godef/a/d.go:9:5-10: defined here as ```go
6981
var Other Thing
@@ -177,15 +189,3 @@ func Things(val []string) []Thing
177189
-- a-hoverdef --
178190
Package a is a package for testing go to definition.
179191

180-
-- NextThing-hoverdef --
181-
```go
182-
type NextThing struct {
183-
Thing
184-
Value int
185-
}
186-
187-
func (*NextThing).Method3() int
188-
func (NextThing).another() string
189-
```
190-
191-
[`a.NextThing` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#NextThing)

gopls/internal/lsp/testdata/godef/hover_generics/hover.go.golden

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
-- Pparam-hoverdef --
2-
```go
3-
type parameter P interface{~int|string}
4-
```
5-
-- Pvar-hoverdef --
6-
```go
7-
type parameter P interface{~int|string}
8-
```
91
-- ValueQfield-hoverdef --
102
```go
113
field Q int

0 commit comments

Comments
 (0)