tools: Index | Files

package tests

import ""

Package tests exports functionality to be used across a variety of gopls tests.


Package Files

normalizer.go tests.go util.go


const (
    // Default runs the standard completion tests.
    CompletionDefault = CompletionTestType(iota)

    // Unimported tests the autocompletion of unimported packages.

    // Deep tests deep completion.

    // Fuzzy tests deep completion and fuzzy matching.

    // CaseSensitive tests case sensitive completion.

    // CompletionRank candidates in test must be valid and in the right relative order.
const (
    // Default runs the standard workspace symbols tests.
    WorkspaceSymbolsDefault = WorkspaceSymbolsTestType(iota)

    // Fuzzy tests workspace symbols with fuzzy matching.

    // CaseSensitive tests workspace symbols with case sensitive.


var UpdateGolden = flag.Bool("golden", false, "Update golden files")

func CheckCompletionOrder Uses

func CheckCompletionOrder(want, got []protocol.CompletionItem, strictScores bool) string

func Context Uses

func Context(t testing.TB) context.Context

func CopyFolderToTempDir Uses

func CopyFolderToTempDir(folder string) (string, error)

func DefaultOptions Uses

func DefaultOptions(o *source.Options)

func Diff Uses

func Diff(t *testing.T, want, got string) string

func DiffCallHierarchyItems Uses

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 DiffCodeLens Uses

func DiffCodeLens(uri span.URI, want, got []protocol.CodeLens) string

func DiffCompletionItems Uses

func DiffCompletionItems(want, got []protocol.CompletionItem) string

DiffCompletionItems prints the diff between expected and actual completion test results.

func DiffDiagnostics Uses

func DiffDiagnostics(uri span.URI, want, got []*source.Diagnostic) string

DiffDiagnostics prints the diff between expected and actual diagnostics test results.

func DiffLinks(mapper *protocol.ColumnMapper, wantLinks []Link, gotLinks []protocol.DocumentLink) string

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 DiffSignatures Uses

func DiffSignatures(spn span.Span, want, got *protocol.SignatureHelp) (string, error)

func DiffSnippets Uses

func DiffSnippets(want string, got *protocol.CompletionItem) string

func DiffSymbols Uses

func DiffSymbols(t *testing.T, uri span.URI, want, got []protocol.DocumentSymbol) string

DiffSymbols prints the diff between expected and actual symbols test results.

func EnableAllAnalyzers Uses

func EnableAllAnalyzers(view source.View, opts *source.Options)

func FilterBuiltins Uses

func FilterBuiltins(src span.Span, items []protocol.CompletionItem) []protocol.CompletionItem

func FindItem Uses

func FindItem(list []protocol.CompletionItem, want completion.CompletionItem) *protocol.CompletionItem

func Normalize Uses

func Normalize(s string, normalizers []Normalizer) string

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

func NormalizePrefix Uses

func NormalizePrefix(s string, normalizers []Normalizer) string

NormalizePrefix normalizes a single path at the front of the input string.

func Run Uses

func Run(t *testing.T, tests Tests, data *Data)

func RunTests Uses

func RunTests(t *testing.T, dataDir string, includeMultiModule bool, f func(*testing.T, *Data))

func SpanName Uses

func SpanName(spn span.Span) string

func ToProtocolCompletionItem Uses

func ToProtocolCompletionItem(item completion.CompletionItem) protocol.CompletionItem

func ToProtocolCompletionItems Uses

func ToProtocolCompletionItems(items []completion.CompletionItem) []protocol.CompletionItem

func WorkspaceSymbolsString Uses

func WorkspaceSymbolsString(ctx context.Context, data *Data, queryURI span.URI, symbols []protocol.SymbolInformation) (string, error)

func WorkspaceSymbolsTestTypeToMatcher Uses

func WorkspaceSymbolsTestTypeToMatcher(typ WorkspaceSymbolsTestType) source.SymbolMatcher

type CallHierarchy Uses

type CallHierarchy map[span.Span]*CallHierarchyResult

type CallHierarchyResult Uses

type CallHierarchyResult struct {
    IncomingCalls, OutgoingCalls []protocol.CallHierarchyItem

type CaseSensitiveCompletions Uses

type CaseSensitiveCompletions map[span.Span][]Completion

type CodeLens Uses

type CodeLens map[span.URI][]protocol.CodeLens

type Completion Uses

type Completion struct {
    CompletionItems []token.Pos

type CompletionItems Uses

type CompletionItems map[token.Pos]*completion.CompletionItem

type CompletionSnippet Uses

type CompletionSnippet struct {
    CompletionItem     token.Pos
    PlainSnippet       string
    PlaceholderSnippet string

type CompletionSnippets Uses

type CompletionSnippets map[span.Span][]CompletionSnippet

type CompletionTestType Uses

type CompletionTestType int

type Completions Uses

type Completions map[span.Span][]Completion

type Data Uses

type Data struct {
    Config                   packages.Config
    Exported                 *packagestest.Exported
    CallHierarchy            CallHierarchy
    CodeLens                 CodeLens
    Diagnostics              Diagnostics
    CompletionItems          CompletionItems
    Completions              Completions
    CompletionSnippets       CompletionSnippets
    UnimportedCompletions    UnimportedCompletions
    DeepCompletions          DeepCompletions
    FuzzyCompletions         FuzzyCompletions
    CaseSensitiveCompletions CaseSensitiveCompletions
    RankCompletions          RankCompletions
    FoldingRanges            FoldingRanges
    Formats                  Formats
    Imports                  Imports
    SemanticTokens           SemanticTokens
    SuggestedFixes           SuggestedFixes
    FunctionExtractions      FunctionExtractions
    Definitions              Definitions
    Implementations          Implementations
    Highlights               Highlights
    References               References
    Renames                  Renames
    PrepareRenames           PrepareRenames
    Symbols                  Symbols

    WorkspaceSymbols WorkspaceSymbols
    Signatures       Signatures
    Links            Links

    ModfileFlagAvailable bool
    // contains filtered or unexported fields

func (*Data) Golden Uses

func (data *Data) Golden(tag string, target string, update func() ([]byte, error)) []byte

func (*Data) Mapper Uses

func (data *Data) Mapper(uri span.URI) (*protocol.ColumnMapper, error)

type DeepCompletions Uses

type DeepCompletions map[span.Span][]Completion

type Definition Uses

type Definition struct {
    Name      string
    IsType    bool
    OnlyHover bool
    Src, Def  span.Span

type Definitions Uses

type Definitions map[span.Span]Definition

type Diagnostics Uses

type Diagnostics map[span.URI][]*source.Diagnostic

type FoldingRanges Uses

type FoldingRanges []span.Span

type Formats Uses

type Formats []span.Span

type FunctionExtractions Uses

type FunctionExtractions map[span.Span]span.Span

type FuzzyCompletions Uses

type FuzzyCompletions map[span.Span][]Completion

type Golden Uses

type Golden struct {
    Filename string
    Archive  *txtar.Archive
    Modified bool

type Highlights Uses

type Highlights map[span.Span][]span.Span

type Implementations Uses

type Implementations map[span.Span][]span.Span

type Imports Uses

type Imports []span.Span
type Link struct {
    Src          span.Span
    Target       string
    NotePosition token.Position
type Links map[span.URI][]Link

type Normalizer Uses

type Normalizer struct {
    // contains filtered or unexported fields

func CollectNormalizers Uses

func CollectNormalizers(exported *packagestest.Exported) []Normalizer

type PrepareRenames Uses

type PrepareRenames map[span.Span]*source.PrepareItem

type RankCompletions Uses

type RankCompletions map[span.Span][]Completion

type References Uses

type References map[span.Span][]span.Span

type Renames Uses

type Renames map[span.Span]string

type SemanticTokens Uses

type SemanticTokens []span.Span

type Signatures Uses

type Signatures map[span.Span]*protocol.SignatureHelp

type SuggestedFixes Uses

type SuggestedFixes map[span.Span][]string

type SymbolInformation Uses

type SymbolInformation map[span.Span]protocol.SymbolInformation

type Symbols Uses

type Symbols map[span.URI][]protocol.DocumentSymbol

type SymbolsChildren Uses

type SymbolsChildren map[string][]protocol.DocumentSymbol

type Tests Uses

type Tests interface {
    CallHierarchy(*testing.T, span.Span, *CallHierarchyResult)
    CodeLens(*testing.T, span.URI, []protocol.CodeLens)
    Diagnostics(*testing.T, span.URI, []*source.Diagnostic)
    Completion(*testing.T, span.Span, Completion, CompletionItems)
    CompletionSnippet(*testing.T, span.Span, CompletionSnippet, bool, CompletionItems)
    UnimportedCompletion(*testing.T, span.Span, Completion, 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)
    FoldingRanges(*testing.T, span.Span)
    Format(*testing.T, span.Span)
    Import(*testing.T, span.Span)
    SemanticTokens(*testing.T, span.Span)
    SuggestedFix(*testing.T, span.Span, []string, int)
    FunctionExtraction(*testing.T, span.Span, span.Span)
    Definition(*testing.T, span.Span, Definition)
    Implementation(*testing.T, span.Span, []span.Span)
    Highlight(*testing.T, span.Span, []span.Span)
    References(*testing.T, span.Span, []span.Span)
    Rename(*testing.T, span.Span, string)
    PrepareRename(*testing.T, span.Span, *source.PrepareItem)
    Symbols(*testing.T, span.URI, []protocol.DocumentSymbol)
    WorkspaceSymbols(*testing.T, span.URI, string, WorkspaceSymbolsTestType)
    SignatureHelp(*testing.T, span.Span, *protocol.SignatureHelp)
    Link(*testing.T, span.URI, []Link)

type UnimportedCompletions Uses

type UnimportedCompletions map[span.Span][]Completion

type WorkspaceSymbols Uses

type WorkspaceSymbols map[WorkspaceSymbolsTestType]map[span.URI][]string

type WorkspaceSymbolsTestType Uses

type WorkspaceSymbolsTestType int

Package tests imports 27 packages (graph) and is imported by 2 packages. Updated 2021-01-21. Refresh now. Tools for package owners.