package
0.0.0-20220218190644-4958d6d39439
Repository: https://github.com/jhump/golang-x-tools.git
Documentation: pkg.go.dev

# README

Testing

LSP has "marker tests" defined in internal/lsp/testdata, as well as traditional tests.

Marker tests

Marker tests have a standard input file, like internal/lsp/testdata/foo/bar.go, and some may have a corresponding golden file, like internal/lsp/testdata/foo/bar.go.golden. The former is the "input" and the latter is the expected output.

Each input file contains annotations like //@suggestedfix("}", "refactor.rewrite"). These annotations are interpreted by test runners to perform certain actions. The expected output after those actions is encoded in the golden file.

When tests are run, each annotation results in a new subtest, which is encoded in the golden file with a heading like,

-- suggestedfix_bar_11_21 --
// expected contents go here
-- suggestedfix_bar_13_20 --
// expected contents go here

The format of these headings vary: they are defined by the Golden function for each annotation. In the case above, the format is: annotation name, file name, annotation line location, annotation character location.

So, if internal/lsp/testdata/foo/bar.go has three suggestedfix annotations, the golden file should have three headers with suggestedfix_bar_xx_yy headings.

To see a list of all available annotations, see the exported "expectations" in tests.go.

To run marker tests,

cd /path/to/tools

# The marker tests are located in "internal/lsp", "internal/lsp/cmd, and
# "internal/lsp/source".
go test ./internal/lsp/...

There are quite a lot of marker tests, so to run one individually, pass the test path and heading into a -run argument:

cd /path/to/tools
go test ./internal/lsp/... -v -run TestLSP/Modules/SuggestedFix/bar_11_21

Resetting marker tests

Sometimes, a change is made to lsp that requires a change to multiple golden files. When this happens, you can run,

cd /path/to/tools
./internal/lsp/reset_golden.sh

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
DiffCallHierarchyItems returns the diff between expected and actual call locations for incoming/outgoing call hierarchies.
No description provided by the author
DiffCompletionItems prints the diff between expected and actual completion test results.
DiffDiagnostics prints the diff between expected and actual diagnostics test results.
DiffLinks takes the links we got and checks if they are located within the source or a Note.
No description provided by the author
No description provided by the author
DiffSymbols prints the diff between expected and actual symbols test results.
No description provided by the author
No description provided by the author
No description provided by the author
Normalize replaces all paths present in s with just the fragment portion this is used to make golden files not depend on the temporary paths of the files.
NormalizeAny replaces occurrences of interface{} in input with any.
NormalizePrefix normalizes a single path at the front of the input string.
No description provided by the author
No description provided by the author
No description provided by the author
StripSubscripts removes type parameter id subscripts.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

CaseSensitive tests case sensitive completion.
Deep tests deep completion.
Default runs the standard completion tests.
Fuzzy tests deep completion and fuzzy matching.
CompletionRank candidates in test must be valid and in the right relative order.
Unimported tests the autocompletion of unimported packages.
CaseSensitive tests workspace symbols with case sensitive.
Default runs the standard workspace symbols tests.
Fuzzy tests workspace symbols with fuzzy matching.

# Variables

No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author