mirror of https://github.com/golang/go.git
internal/lsp/tests: fix reset of golden files
internal/lsp/reset_golden.sh fails when golden file does not exist, so skip loading the golden file on update. Additionally, add the missing primarymod directory as the update destination path so that golden files are placed under the primarymod directory. However, keep the location of summary.txt.golden in the same directory as the primarymod directory. As a result, some unnecessary data was deleted. Change-Id: I98120c8b7d483174644600786fd30acdc2e4c52e Reviewed-on: https://go-review.googlesource.com/c/tools/+/219577 Run-TryBot: Rohan Challa <rohan@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rohan Challa <rohan@golang.org>
This commit is contained in:
parent
753a1d49df
commit
ca8c272a4d
|
|
@ -1,24 +0,0 @@
|
|||
-- summary --
|
||||
CompletionsCount = 0
|
||||
CompletionSnippetCount = 0
|
||||
UnimportedCompletionsCount = 0
|
||||
DeepCompletionsCount = 0
|
||||
FuzzyCompletionsCount = 0
|
||||
RankedCompletionsCount = 0
|
||||
CaseSensitiveCompletionsCount = 0
|
||||
DiagnosticsCount = 0
|
||||
FoldingRangesCount = 0
|
||||
FormatCount = 0
|
||||
ImportCount = 0
|
||||
SuggestedFixCount = 0
|
||||
DefinitionsCount = 0
|
||||
TypeDefinitionsCount = 0
|
||||
HighlightsCount = 0
|
||||
ReferencesCount = 0
|
||||
RenamesCount = 0
|
||||
PrepareRenamesCount = 0
|
||||
SymbolsCount = 0
|
||||
SignaturesCount = 0
|
||||
LinksCount = 0
|
||||
ImplementationsCount = 0
|
||||
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
-- funcexample-hover --
|
||||
func cgo.Example()
|
||||
|
|
@ -90,29 +90,6 @@ func a.AStuff()
|
|||
```go
|
||||
func a.AStuff()
|
||||
```
|
||||
-- PackageFoo-definition --
|
||||
foo/foo.go:1:1-30:16: defined here as myFoo "golang.org/x/tools/internal/lsp/foo" //@mark(myFoo, "myFoo"),godef("foo", PackageFoo),godef("myFoo", myFoo)
|
||||
-- PackageFoo-definition-json --
|
||||
{
|
||||
"span": {
|
||||
"uri": "file://foo/foo.go",
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 1,
|
||||
"offset": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 30,
|
||||
"column": 16,
|
||||
"offset": 922
|
||||
}
|
||||
},
|
||||
"description": "myFoo \"golang.org/x/tools/internal/lsp/foo\" //@mark(myFoo, \"myFoo\"),godef(\"foo\", PackageFoo),godef(\"myFoo\", myFoo)"
|
||||
}
|
||||
|
||||
-- PackageFoo-hover --
|
||||
myFoo "golang.org/x/tools/internal/lsp/foo" //@mark(myFoo, "myFoo"),godef("foo", PackageFoo),godef("myFoo", myFoo)
|
||||
|
||||
-- S1-definition --
|
||||
godef/b/b.go:8:6-8: defined here as ```go
|
||||
S1 struct {
|
||||
|
|
@ -325,28 +302,6 @@ field F2 int
|
|||
```go
|
||||
field F2 int
|
||||
```
|
||||
-- Stuff-definition --
|
||||
godef/a/a.go:9:6-11: defined here as func a.Stuff()
|
||||
-- Stuff-definition-json --
|
||||
{
|
||||
"span": {
|
||||
"uri": "file://godef/a/a.go",
|
||||
"start": {
|
||||
"line": 9,
|
||||
"column": 6,
|
||||
"offset": 95
|
||||
},
|
||||
"end": {
|
||||
"line": 9,
|
||||
"column": 11,
|
||||
"offset": 100
|
||||
}
|
||||
},
|
||||
"description": "func a.Stuff()"
|
||||
}
|
||||
|
||||
-- Stuff-hover --
|
||||
func a.Stuff()
|
||||
-- bX-definition --
|
||||
godef/b/b.go:37:7-8: defined here as ```go
|
||||
const X untyped int = 0
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
-- -signature --
|
||||
|
||||
-- Bar(float64, ...byte)-signature --
|
||||
Bar(float64, ...byte)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
-- -signature --
|
||||
|
||||
-- baz(at AliasType, b bool)-signature --
|
||||
baz(at AliasType, b bool)
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ const (
|
|||
overlayFileSuffix = ".overlay"
|
||||
goldenFileSuffix = ".golden"
|
||||
inFileSuffix = ".in"
|
||||
summaryFile = "summary.txt.golden"
|
||||
summaryFile = "summary.txt"
|
||||
testModule = "golang.org/x/tools/internal/lsp"
|
||||
)
|
||||
|
||||
|
|
@ -296,17 +296,19 @@ func Load(t testing.TB, exporter packagestest.Exporter, dir string) []*Data {
|
|||
mappers: map[span.URI]*protocol.ColumnMapper{},
|
||||
}
|
||||
|
||||
summary := filepath.Join(filepath.FromSlash(folder), summaryFile)
|
||||
if _, err := os.Stat(summary); os.IsNotExist(err) {
|
||||
t.Fatalf("could not find golden file summary.txt in %#v", folder)
|
||||
}
|
||||
archive, err := txtar.ParseFile(summary)
|
||||
if err != nil {
|
||||
t.Fatalf("could not read golden file %v/%v: %v", folder, summary, err)
|
||||
}
|
||||
datum.golden["summary.txt"] = &Golden{
|
||||
Filename: summary,
|
||||
Archive: archive,
|
||||
if !*UpdateGolden {
|
||||
summary := filepath.Join(filepath.FromSlash(folder), summaryFile+goldenFileSuffix)
|
||||
if _, err := os.Stat(summary); os.IsNotExist(err) {
|
||||
t.Fatalf("could not find golden file summary.txt in %#v", folder)
|
||||
}
|
||||
archive, err := txtar.ParseFile(summary)
|
||||
if err != nil {
|
||||
t.Fatalf("could not read golden file %v/%v: %v", folder, summary, err)
|
||||
}
|
||||
datum.golden[summaryFile] = &Golden{
|
||||
Filename: summary,
|
||||
Archive: archive,
|
||||
}
|
||||
}
|
||||
|
||||
modules, _ := packagestest.GroupFilesByModules(folder)
|
||||
|
|
@ -786,7 +788,7 @@ func checkData(t *testing.T, data *Data) {
|
|||
fmt.Fprintf(buf, "LinksCount = %v\n", linksCount)
|
||||
fmt.Fprintf(buf, "ImplementationsCount = %v\n", len(data.Implementations))
|
||||
|
||||
want := string(data.Golden("summary", "summary.txt", func() ([]byte, error) {
|
||||
want := string(data.Golden("summary", summaryFile, func() ([]byte, error) {
|
||||
return buf.Bytes(), nil
|
||||
}))
|
||||
got := buf.String()
|
||||
|
|
@ -828,8 +830,12 @@ func (data *Data) Golden(tag string, target string, update func() ([]byte, error
|
|||
if !*UpdateGolden {
|
||||
data.t.Fatalf("could not find golden file %v: %v", fragment, tag)
|
||||
}
|
||||
var subdir string
|
||||
if fragment != summaryFile {
|
||||
subdir = "primarymod"
|
||||
}
|
||||
golden = &Golden{
|
||||
Filename: filepath.Join(data.dir, fragment+goldenFileSuffix),
|
||||
Filename: filepath.Join(data.dir, subdir, fragment+goldenFileSuffix),
|
||||
Archive: &txtar.Archive{},
|
||||
Modified: true,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue