🤫 Don't require t.Helper in functions passed to synctest.Test#51
Merged
kulti merged 2 commits intokulti:masterfrom Sep 15, 2025
Merged
🤫 Don't require t.Helper in functions passed to synctest.Test#51kulti merged 2 commits intokulti:masterfrom
kulti merged 2 commits intokulti:masterfrom
Conversation
4307dcf to
b7a5fed
Compare
Go 1.25 made the `testing/synctest` package generally available. The
package introduces the `synctest.Test` function, to be used like this:
```go
func TestMyFeature(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
// Do stuff that uses goroutines
})
}
```
Sadly, `thelper` triggers if the anonymous function passed to
`synctest.Test` doesn't call `t.Helper()`. The issue is that this
anonymous function isn't a helper, it's more like a sub-test.
This PR extends `thelper` to grant an exception to functions passed to
`synctest.Test`, just like functions passed to `t.Run` or `b.Run`.
This requires updating to Go 1.25, so this PR is stacked on top of kulti#50.
b7a5fed to
9368dfb
Compare
Contributor
Author
|
Hey @kulti, this one is ready for your review :) |
kulti
approved these changes
Sep 14, 2025
Owner
kulti
left a comment
There was a problem hiding this comment.
Sorry for the delayed reply. Great job! I suppose we can merge it. The following comments are not so important. I can improve it later.
Contributor
Author
|
I've updated the code. No point in you fixing it later if I can fix it now ;) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Go 1.25 made the
testing/synctestpackage generally available. Thepackage introduces the
synctest.Testfunction, to be used like this:Sadly,
thelpertriggers if the anonymous function passed tosynctest.Testdoesn't callt.Helper(). The issue is that thisanonymous function isn't a helper, it's more like a sub-test. This
has been reported in #48.
This PR extends
thelperto grant an exception to functions passed tosynctest.Test, just like functions passed tot.Runorb.Run.This requires updating to Go 1.25, so this PR is stacked on top of #50.