From 88b1720de6a2178e560c7410577522ea5131f254 Mon Sep 17 00:00:00 2001 From: Rohan Challa Date: Wed, 19 Feb 2020 16:46:42 -0500 Subject: [PATCH] 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 Reviewed-by: Rebecca Stambler TryBot-Result: Gobot Gobot --- internal/lsp/testdata/lsp/primarymod/links/links.go | 2 -- internal/lsp/testdata/lsp/summary.txt.golden | 2 +- internal/lsp/tests/tests.go | 4 ++-- internal/lsp/tests/util.go | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/internal/lsp/testdata/lsp/primarymod/links/links.go b/internal/lsp/testdata/lsp/primarymod/links/links.go index b5766abdeb..be15ddb6a9 100644 --- a/internal/lsp/testdata/lsp/primarymod/links/links.go +++ b/internal/lsp/testdata/lsp/primarymod/links/links.go @@ -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`) ) diff --git a/internal/lsp/testdata/lsp/summary.txt.golden b/internal/lsp/testdata/lsp/summary.txt.golden index 4ab35ea809..48451420f4 100644 --- a/internal/lsp/testdata/lsp/summary.txt.golden +++ b/internal/lsp/testdata/lsp/summary.txt.golden @@ -23,6 +23,6 @@ WorkspaceSymbolsCount = 2 FuzzyWorkspaceSymbolsCount = 3 CaseSensitiveWorkspaceSymbolsCount = 2 SignaturesCount = 23 -LinksCount = 9 +LinksCount = 8 ImplementationsCount = 5 diff --git a/internal/lsp/tests/tests.go b/internal/lsp/tests/tests.go index c605b079ab..741df0fb08 100644 --- a/internal/lsp/tests/tests.go +++ b/internal/lsp/tests/tests.go @@ -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) { diff --git a/internal/lsp/tests/util.go b/internal/lsp/tests/util.go index dcea4662b9..b81cfd01e6 100644 --- a/internal/lsp/tests/util.go +++ b/internal/lsp/tests/util.go @@ -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)