Atlas › Test
skips_test_with_parallelize:ignore
Exact test identity: go.temporal.io/server/tools/parallelize/TestProcessFile/skips_test_with_parallelize:ignore
- Package
go.temporal.io/server/tools/parallelize
- Suite / test hierarchy
TestProcessFile/skips_test_with_parallelize:ignore
- Test
skips_test_with_parallelize:ignore
- Introduced at
- parallelize.go ×2 Frontier kind: Joint frontier
- Covered ranges
- 26
- Covered lines
- 62
- Covered files
- 1
Covered source
Expand a file to inspect source; the > gutter marks covered lines.
go.temporal.io/server/tools/parallelize/parallelize.go 62 covered LOC · 26 ranges
Open complete file
43
}
44
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.
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
}
66
continue
67
}
69
>
if paramName == "" {
70
continue
71
}
73
continue
74
}
77
}
78
bodyLine := fset.Position(fn.Body.Lbrace).Line
80
}
81
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).
121
>
if fn.Recv != nil {
122
return false // method, not a function
123
}
125
return false
126
}
128
return false
129
}
131
}
132
133
// testingTParamName returns the name of the *testing.T parameter, or "" if not found.
134
>
func testingTParamName(fn *ast.FuncDecl) string {
parallelize.go
135
>
if fn.Type.Params == nil || len(fn.Type.Params.List) == 0 {
136
return ""
137
}
139
>
starExpr, ok := field.Type.(*ast.StarExpr)
140
>
if !ok {
141
continue
142
}
144
>
if !ok {
145
continue
146
}
148
>
if !ok {
149
continue
150
}
151
>
if pkg.Name == "testing" && selExpr.Sel.Name == "T" {
parallelize.go
152
>
if len(field.Names) > 0 {
153
>
return field.Names[0].Name
154
>
}
155
}
156
}
159
160
// hasNoLintComment checks for //parallelize:ignore in the function's doc comment.
162
>
if fn.Doc == nil {
163
return false
164
}
166
>
if strings.Contains(c.Text, "parallelize:ignore") {
167
>
return true
168
>
}
169
}
170
return false
172
173
// hasParallelCall checks if the function body already contains <param>.Parallel().
174
>
func hasParallelCall(body *ast.BlockStmt, paramName string) bool {
parallelize.go
175
>
found := false
176
>
ast.Inspect(body, func(n ast.Node) bool {
177
>
if found {
178
return false
179
}
181
>
if !ok {
182
>
return true
183
>
}
184
>
sel, ok := call.Fun.(*ast.SelectorExpr)
185
>
if !ok {
186
return true
187
}
189
>
if !ok {
190
return true
191
}
192
>
if ident.Name == paramName && sel.Sel.Name == "Parallel" {
parallelize.go
193
found = true
194
}
196
})
198
}