Skip to content

Commit 5a267c8

Browse files
committed
cmd/vet: bring in pass to catch invalid uses of testing.T in goroutines
Add "go/analysis/passes/testinggoroutine" from x/tools and vendor its source in. This pass will catch misuses of: * testing.T.Fail* * testing.T.Fatal* * testing.T.Skip* inside goroutines explicitly started by the go keyword. The pass was implemented in CL 212920. While here, found 2 misuses in: * database/sql/sql_test.go * runtime/syscall_windows_test.go and fixed them in CL 235527. Fixes #5746 Change-Id: I1740ad3f1d677bb5d78dc5d8d66bac6ec287a2b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/235677 Run-TryBot: Emmanuel Odeke <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Trust: Emmanuel Odeke <[email protected]>
1 parent 063a91c commit 5a267c8

File tree

2 files changed

+156
-0
lines changed

2 files changed

+156
-0
lines changed

src/cmd/vendor/golang.org/x/tools/go/analysis/passes/testinggoroutine/testinggoroutine.go

Lines changed: 154 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/vet/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"golang.org/x/tools/go/analysis/passes/stdmethods"
2525
"golang.org/x/tools/go/analysis/passes/stringintconv"
2626
"golang.org/x/tools/go/analysis/passes/structtag"
27+
"golang.org/x/tools/go/analysis/passes/testinggoroutine"
2728
"golang.org/x/tools/go/analysis/passes/tests"
2829
"golang.org/x/tools/go/analysis/passes/unmarshal"
2930
"golang.org/x/tools/go/analysis/passes/unreachable"
@@ -55,6 +56,7 @@ func main() {
5556
stringintconv.Analyzer,
5657
structtag.Analyzer,
5758
tests.Analyzer,
59+
testinggoroutine.Analyzer,
5860
unmarshal.Analyzer,
5961
unreachable.Analyzer,
6062
unsafeptr.Analyzer,

0 commit comments

Comments
 (0)