MCPcopy Create free account
hub / github.com/temporalio/temporal / testingTParamName

Function testingTParamName

tools/parallelize/parallelize.go:134–158  ·  view source on GitHub ↗

testingTParamName returns the name of the *testing.T parameter, or "" if not found.

(fn *ast.FuncDecl)

Source from the content-addressed store, hash-verified

132
133// testingTParamName returns the name of the *testing.T parameter, or "" if not found.
134func testingTParamName(fn *ast.FuncDecl) string {
135 if fn.Type.Params == nil || len(fn.Type.Params.List) == 0 {
136 return ""
137 }
138 for _, field := range fn.Type.Params.List {
139 starExpr, ok := field.Type.(*ast.StarExpr)
140 if !ok {
141 continue
142 }
143 selExpr, ok := starExpr.X.(*ast.SelectorExpr)
144 if !ok {
145 continue
146 }
147 pkg, ok := selExpr.X.(*ast.Ident)
148 if !ok {
149 continue
150 }
151 if pkg.Name == "testing" && selExpr.Sel.Name == "T" {
152 if len(field.Names) > 0 {
153 return field.Names[0].Name
154 }
155 }
156 }
157 return ""
158}
159
160// hasNoLintComment checks for //parallelize:ignore in the function's doc comment.
161func hasNoLintComment(fn *ast.FuncDecl) bool {

Callers 2

processFileFunction · 0.85
isTestFuncFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected