internal/lsp/tests: fix regexp for removing links that contain versions

This change fixes the regex that removes the versions for links so that tests will still run under GOPATH mode. It also removes a link for an import that needed to be downloaded.

Change-Id: I7ed4f500d1bd9d2136188d30952eedb8d8aee6e4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/220140
Run-TryBot: Rohan Challa <rohan@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Rohan Challa 2020-02-19 16:46:42 -05:00
parent d3d48f09aa
commit 88b1720de6
4 changed files with 4 additions and 6 deletions

View File

@ -7,8 +7,6 @@ import (
_ "database/sql" //@link(`database/sql`, `https://pkg.go.dev/database/sql`)
errors "golang.org/x/xerrors" //@link(`golang.org/x/xerrors`, `https://pkg.go.dev/golang.org/x/xerrors`)
_ "example.com/extramodule/pkg" //@link(`example.com/extramodule/pkg`,`https://pkg.go.dev/example.com/extramodule@v1.0.0/pkg`)
)

View File

@ -23,6 +23,6 @@ WorkspaceSymbolsCount = 2
FuzzyWorkspaceSymbolsCount = 3
CaseSensitiveWorkspaceSymbolsCount = 2
SignaturesCount = 23
LinksCount = 9
LinksCount = 8
ImplementationsCount = 5

View File

@ -704,9 +704,9 @@ func Run(t *testing.T, tests Tests, data *Data) {
// If we are testing GOPATH, then we do not want links with
// the versions attached (pkg.go.dev/repoa/moda@v1.1.0/pkg).
if data.Exported.Exporter == packagestest.GOPATH {
re := regexp.MustCompile(`@(.+?)/`)
re := regexp.MustCompile(`@v\d+\.\d+\.[\w-]+`)
for i, link := range wantLinks {
wantLinks[i].Target = re.ReplaceAllString(link.Target, "/")
wantLinks[i].Target = re.ReplaceAllString(link.Target, "")
}
}
t.Run(uriName(uri), func(t *testing.T) {

View File

@ -49,7 +49,7 @@ func DiffLinks(mapper *protocol.ColumnMapper, wantLinks []Link, gotLinks []proto
if target, ok := links[spn]; ok {
delete(links, spn)
if target != link.Target {
return fmt.Sprintf("for %v want %v, got %v\n", spn, link.Target, target)
return fmt.Sprintf("for %v want %v, got %v\n", spn, target, link.Target)
}
} else {
return fmt.Sprintf("unexpected link %v:%v\n", spn, link.Target)