Documentation ¶
Overview ¶
Package tests exports functionality to be used across a variety of gopls tests.
Index ¶
- Constants
- Variables
- func CheckCompletionOrder(want, got []protocol.CompletionItem, strictScores bool) string
- func Context(t testing.TB) context.Context
- func DefaultOptions(o *source.Options)
- func DiffCallHierarchyItems(gotCalls []protocol.CallHierarchyItem, ...) string
- func DiffCompletionItems(want, got []protocol.CompletionItem) string
- func DiffLinks(mapper *protocol.Mapper, wantLinks []Link, gotLinks []protocol.DocumentLink) string
- func DiffMarkdown(want, got string) string
- func DiffSignatures(spn span.Span, want, got *protocol.SignatureHelp) string
- func DiffSnippets(want string, got *protocol.CompletionItem) string
- func FilterBuiltins(src span.Span, items []protocol.CompletionItem) []protocol.CompletionItem
- func FindItem(list []protocol.CompletionItem, want completion.CompletionItem) *protocol.CompletionItem
- func NormalizeAny(input string) string
- func Run(t *testing.T, tests Tests, data *Data)
- func RunTests(t *testing.T, dataDir string, includeMultiModule bool, ...)
- func SpanName(spn span.Span) string
- type AddImport
- type CallHierarchy
- type CallHierarchyResult
- type CaseSensitiveCompletions
- type Completion
- type CompletionItems
- type CompletionSnippet
- type CompletionSnippets
- type CompletionTestType
- type Completions
- type Data
- type DeepCompletions
- type FuzzyCompletions
- type Golden
- type InlayHints
- type Link
- type Links
- type MethodExtractions
- type PrepareRenames
- type RankCompletions
- type Renames
- type SelectionRanges
- type SemanticTokens
- type Signatures
- type SuggestedFix
- type SuggestedFixes
- type Tests
Constants ¶
const ( // Default runs the standard completion tests. CompletionDefault = CompletionTestType(iota) // Deep tests deep completion. CompletionDeep // Fuzzy tests deep completion and fuzzy matching. CompletionFuzzy // CaseSensitive tests case sensitive completion. CompletionCaseSensitive // CompletionRank candidates in test must be valid and in the right relative order. CompletionRank )
Variables ¶
var UpdateGolden = flag.Bool("golden", false, "Update golden files")
Functions ¶
func CheckCompletionOrder ¶
func CheckCompletionOrder(want, got []protocol.CompletionItem, strictScores bool) string
func DefaultOptions ¶
func DiffCallHierarchyItems ¶
func DiffCallHierarchyItems(gotCalls []protocol.CallHierarchyItem, expectedCalls []protocol.CallHierarchyItem) string
DiffCallHierarchyItems returns the diff between expected and actual call locations for incoming/outgoing call hierarchies
func DiffCompletionItems ¶
func DiffCompletionItems(want, got []protocol.CompletionItem) string
DiffCompletionItems prints the diff between expected and actual completion test results.
The diff will be formatted using '-' and '+' for want and got, respectively.
func DiffLinks ¶
DiffLinks takes the links we got and checks if they are located within the source or a Note. If the link is within a Note, the link is removed. Returns an diff comment if there are differences and empty string if no diffs.
func DiffMarkdown ¶ added in v0.12.0
DiffMarkdown compares two markdown strings produced by parsing go doc comments.
For go1.19 and later, markdown conversion is done using go/doc/comment. Compared to the newer version, the older version has extra escapes, and treats code blocks slightly differently.
func DiffSignatures ¶
func DiffSignatures(spn span.Span, want, got *protocol.SignatureHelp) string
func DiffSnippets ¶
func DiffSnippets(want string, got *protocol.CompletionItem) string
func FilterBuiltins ¶
func FilterBuiltins(src span.Span, items []protocol.CompletionItem) []protocol.CompletionItem
func FindItem ¶
func FindItem(list []protocol.CompletionItem, want completion.CompletionItem) *protocol.CompletionItem
func NormalizeAny ¶
NormalizeAny replaces occurrences of interface{} in input with any.
In Go 1.18, standard library functions were changed to use the 'any' alias in place of interface{}, which affects their type string.
Types ¶
type CallHierarchy ¶
type CallHierarchy = map[span.Span]*CallHierarchyResult
These type names apparently avoid the need to repeat the type in the field name and the make() expression.
type CallHierarchyResult ¶
type CallHierarchyResult struct {
IncomingCalls, OutgoingCalls []protocol.CallHierarchyItem
}
type CaseSensitiveCompletions ¶
type CaseSensitiveCompletions = map[span.Span][]Completion
type Completion ¶
type CompletionItems ¶
type CompletionItems = map[token.Pos]*completion.CompletionItem
type CompletionSnippet ¶
type CompletionSnippets ¶
type CompletionSnippets = map[span.Span][]CompletionSnippet
type CompletionTestType ¶
type CompletionTestType int
type Completions ¶
type Completions = map[span.Span][]Completion
type Data ¶
type Data struct { Config packages.Config Exported *packagestest.Exported CallHierarchy CallHierarchy CompletionItems CompletionItems Completions Completions CompletionSnippets CompletionSnippets DeepCompletions DeepCompletions FuzzyCompletions FuzzyCompletions CaseSensitiveCompletions CaseSensitiveCompletions RankCompletions RankCompletions SemanticTokens SemanticTokens SuggestedFixes SuggestedFixes MethodExtractions MethodExtractions Renames Renames InlayHints InlayHints PrepareRenames PrepareRenames Signatures Signatures Links Links AddImport AddImport SelectionRanges SelectionRanges ModfileFlagAvailable bool // contains filtered or unexported fields }
type DeepCompletions ¶
type DeepCompletions = map[span.Span][]Completion
type FuzzyCompletions ¶
type FuzzyCompletions = map[span.Span][]Completion
type InlayHints ¶
type PrepareRenames ¶
type PrepareRenames = map[span.Span]*source.PrepareItem
type RankCompletions ¶
type RankCompletions = map[span.Span][]Completion
type SelectionRanges ¶ added in v0.12.0
type SemanticTokens ¶
type Signatures ¶
type Signatures = map[span.Span]*protocol.SignatureHelp
type SuggestedFix ¶
type SuggestedFix struct {
ActionKind, Title string
}
type SuggestedFixes ¶
type SuggestedFixes = map[span.Span][]SuggestedFix
type Tests ¶
type Tests interface { CallHierarchy(*testing.T, span.Span, *CallHierarchyResult) Completion(*testing.T, span.Span, Completion, CompletionItems) CompletionSnippet(*testing.T, span.Span, CompletionSnippet, bool, CompletionItems) DeepCompletion(*testing.T, span.Span, Completion, CompletionItems) FuzzyCompletion(*testing.T, span.Span, Completion, CompletionItems) CaseSensitiveCompletion(*testing.T, span.Span, Completion, CompletionItems) RankCompletion(*testing.T, span.Span, Completion, CompletionItems) SemanticTokens(*testing.T, span.Span) SuggestedFix(*testing.T, span.Span, []SuggestedFix, int) MethodExtraction(*testing.T, span.Span, span.Span) InlayHints(*testing.T, span.Span) Rename(*testing.T, span.Span, string) PrepareRename(*testing.T, span.Span, *source.PrepareItem) SignatureHelp(*testing.T, span.Span, *protocol.SignatureHelp) Link(*testing.T, span.URI, []Link) AddImport(*testing.T, span.URI, string) SelectionRanges(*testing.T, span.Span) }
The Tests interface abstracts the LSP-based implementation of the marker test operators appearing in files beneath ../testdata/.
TODO(adonovan): reduce duplication; see https://github.com/golang/go/issues/54845. There is only one implementation (*runner in ../lsp_test.go), so we can abolish the interface now.