- Notifications
You must be signed in to change notification settings - Fork1k
ci: improve 'tfail in goroutine' ruleguard rule#19682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -182,32 +182,28 @@ func doNotCallTFailNowInsideGoroutine(m dsl.Matcher) { | ||
m.Match(` | ||
go func($*_){ | ||
$*_ | ||
require.$_($*_) | ||
$*_ | ||
}($*_)`). | ||
Comment on lines 183 to -189 MemberAuthor
| ||
Report("Do not call functions that may call t.FailNow in a goroutine, as this can cause data races (see testing.go:834)") | ||
// require.Eventually runs the function in a goroutine. | ||
m.Match(` | ||
require.Eventually(t, func() bool { | ||
$*_ | ||
require.$_($*_) | ||
$*_ | ||
}, $*_)`). | ||
Report("Do not call functions that may call t.FailNow in a goroutine, as this can cause data races (see testing.go:834)") | ||
m.Match(` | ||
go func($*_){ | ||
$*_ | ||
t.$fail($*_) | ||
$*_ | ||
}($*_)`). | ||
At(m["fail"]). | ||
Where(m["fail"].Text.Matches("^(FailNow|Fatal|Fatalf)$")). | ||
Report("Do not call functions that may call t.FailNow in a goroutine, as this can cause data races (see testing.go:834)") | ||
} | ||
Comment on lines 199 to 208 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. We apply the same idea here, but with a caveat that if there's some other | ||
Uh oh!
There was an error while loading.Please reload this page.