From 0d653b92c519c134869ad7ef593ca64dd7c76f79 Mon Sep 17 00:00:00 2001 From: Daisuke Suzuki Date: Sat, 29 Feb 2020 14:47:19 +0900 Subject: [PATCH] internal/lsp/tests: fix WorkspaceSymbols tests The tests will not run because there is no workspacesymbol marker. Therefore, restore testdata used in WorkspaceSymbols tests, and initialize data so that the tests run even if the target of the marker is 0. Change-Id: I051b842183b7e23bb746cc282fc3921a90ca8df1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/221617 Reviewed-by: Heschi Kreinick Run-TryBot: Heschi Kreinick TryBot-Result: Gobot Gobot --- .../lsp/primarymod/workspacesymbol/workspacesymbol.go | 9 +++++++++ internal/lsp/testdata/lsp/summary.txt.golden | 2 +- internal/lsp/tests/tests.go | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 internal/lsp/testdata/lsp/primarymod/workspacesymbol/workspacesymbol.go diff --git a/internal/lsp/testdata/lsp/primarymod/workspacesymbol/workspacesymbol.go b/internal/lsp/testdata/lsp/primarymod/workspacesymbol/workspacesymbol.go new file mode 100644 index 0000000000..7ab22904f7 --- /dev/null +++ b/internal/lsp/testdata/lsp/primarymod/workspacesymbol/workspacesymbol.go @@ -0,0 +1,9 @@ +package workspacesymbol + +/*@ +workspacesymbol("") // The result is 0 symbols due to the limit(golang.org/cl/220939). +workspacesymbol("workspacesymbolvar", + WorkspaceSymbolVariableA, + WorkspaceSymbolVariableB, +) +*/ diff --git a/internal/lsp/testdata/lsp/summary.txt.golden b/internal/lsp/testdata/lsp/summary.txt.golden index b57523ff62..08bd0b7aa0 100644 --- a/internal/lsp/testdata/lsp/summary.txt.golden +++ b/internal/lsp/testdata/lsp/summary.txt.golden @@ -19,7 +19,7 @@ ReferencesCount = 9 RenamesCount = 23 PrepareRenamesCount = 7 SymbolsCount = 3 -WorkspaceSymbolsCount = 0 +WorkspaceSymbolsCount = 2 FuzzyWorkspaceSymbolsCount = 3 CaseSensitiveWorkspaceSymbolsCount = 2 SignaturesCount = 24 diff --git a/internal/lsp/tests/tests.go b/internal/lsp/tests/tests.go index 9e796818eb..efdff5957a 100644 --- a/internal/lsp/tests/tests.go +++ b/internal/lsp/tests/tests.go @@ -1112,18 +1112,21 @@ func (data *Data) collectWorkspaceSymbols(typ WorkspaceSymbolsTestType) func(str switch typ { case WorkspaceSymbolsFuzzy: return func(query string, targets []span.Span) { + data.FuzzyWorkspaceSymbols[query] = make([]protocol.SymbolInformation, 0, len(targets)) for _, target := range targets { data.FuzzyWorkspaceSymbols[query] = append(data.FuzzyWorkspaceSymbols[query], data.symbolInformation[target]) } } case WorkspaceSymbolsCaseSensitive: return func(query string, targets []span.Span) { + data.CaseSensitiveWorkspaceSymbols[query] = make([]protocol.SymbolInformation, 0, len(targets)) for _, target := range targets { data.CaseSensitiveWorkspaceSymbols[query] = append(data.CaseSensitiveWorkspaceSymbols[query], data.symbolInformation[target]) } } default: return func(query string, targets []span.Span) { + data.WorkspaceSymbols[query] = make([]protocol.SymbolInformation, 0, len(targets)) for _, target := range targets { data.WorkspaceSymbols[query] = append(data.WorkspaceSymbols[query], data.symbolInformation[target]) }