testinggoroutine

Imports

Imports #

_ "embed"
"fmt"
"go/ast"
"go/token"
"go/types"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/analysis/passes/internal/analysisutil"
"golang.org/x/tools/go/ast/inspector"
"golang.org/x/tools/go/types/typeutil"
"go/ast"
"go/types"
"golang.org/x/tools/internal/typeparams"

Constants & Variables

Analyzer var #

var Analyzer = *ast.UnaryExpr

doc var #

go:embed doc.go

var doc string

forbidden var #

var forbidden = []string{...}

reportSubtest var #

var reportSubtest bool

Structs

asyncCall struct #

asyncCall describes a region of code that needs to be checked for t.Forbidden() calls as it is started asynchronously from an async node go fun() or t.Run(name, fun).

type asyncCall struct {
region ast.Node
async ast.Node
scope ast.Node
fun ast.Expr
}

Functions

forbiddenMethod function #

forbiddenMethod decomposes a call x.m() into (x, x.m, m) where x is a variable, x.m is a selection, and m is the static callee m. Returns (nil, nil, nil) if call is not of this form.

func forbiddenMethod(info *types.Info, call *ast.CallExpr) (*types.Var, *types.Selection, *types.Func)

formatMethod function #

func formatMethod(sel *types.Selection, fn *types.Func) string

funcIdent function #

func funcIdent(fun ast.Expr) *ast.Ident

funcLitInScope function #

funcLitInScope returns a FuncLit that id is at least initially assigned to. TODO: This is closely tied to id.Obj which is deprecated.

func funcLitInScope(id *ast.Ident) *ast.FuncLit

goAsyncCall function #

goAsyncCall returns the extent of a call from a go fun() statement.

func goAsyncCall(info *types.Info, goStmt *ast.GoStmt, toDecl func(*types.Func) *ast.FuncDecl) *asyncCall

hasBenchmarkOrTestParams function #

func hasBenchmarkOrTestParams(fnDecl *ast.FuncDecl) bool

init function #

func init()

isMethodNamed function #

isMethodNamed returns true if f is a method defined in package with the path pkgPath with a name in names.

func isMethodNamed(f *types.Func, pkgPath string, names ...string) bool

localFunctionDecls function #

localFunctionDecls returns a mapping from *types.Func to *ast.FuncDecl in files.

func localFunctionDecls(info *types.Info, files []*ast.File) (func(*types.Func) *ast.FuncDecl)

run function #

func run(pass *analysis.Pass) (interface{}, error)

tRunAsyncCall function #

tRunAsyncCall returns the extent of a call from a t.Run("name", fun) expression.

func tRunAsyncCall(info *types.Info, call *ast.CallExpr) *asyncCall

typeIsTestingDotTOrB function #

func typeIsTestingDotTOrB(expr ast.Expr) (string, bool)

withinScope function #

withinScope returns true if x.Pos() is in [scope.Pos(), scope.End()].

func withinScope(scope ast.Node, x *types.Var) bool

Generated with Arrow