Atlas › Test

skips_non-test_functions

Exact test identity: go.temporal.io/server/tools/parallelize/TestProcessFile/skips_non-test_functions

Package
go.temporal.io/server/tools/parallelize
Suite / test hierarchy
TestProcessFile/skips_non-test_functions
Test
skips_non-test_functions
Introduced at
parallelize.go ×1 Frontier kind: Joint frontier
Covered ranges
9
Covered lines
24
Covered files
1

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/tools/parallelize/parallelize.go 24 covered LOC · 9 ranges

Open complete file

43 }
44
45 > func processFile(path string) error { parallelize.go
46 > fset := token.NewFileSet()
47 > f, err := parser.ParseFile(fset, path, nil, parser.ParseComments)
48 > if err != nil {
49 return fmt.Errorf("parse %s: %w", path, err)
50 }
52 // Collect line numbers where we need to insert t.Parallel().
53 // Each entry is the line of the opening '{' of the test function body.
54 > type insertion struct { parallelize.go
55 > line int // line number of the '{' opening the function body
56 > paramName string // name of the *testing.T parameter
57 > }
58 > var insertions []insertion
59 >
60 > for _, decl := range f.Decls {
61 > fn, ok := decl.(*ast.FuncDecl)
62 > if !ok {
63 > continue
64 }
65 > if !isTestFunc(fn) { parallelize.go
66 > continue parallelize.go
67 }
68 paramName := testingTParamName(fn)
80 }
81
82 > if len(insertions) == 0 { parallelize.go
83 > return nil parallelize.go
84 > }
85
86 // Sort by line descending so insertions don't shift line numbers of subsequent insertions.
118
119 // isTestFunc returns true for func TestXxx(t *testing.T).
120 > func isTestFunc(fn *ast.FuncDecl) bool { parallelize.go
121 > if fn.Recv != nil {
122 return false // method, not a function
123 }
124 > if !strings.HasPrefix(fn.Name.Name, "Test") { parallelize.go
125 > return false parallelize.go
126 > }
127 if fn.Body == nil {
128 return false