-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add T.Context() *Context*: Go 1.24 adds a `Context()` method to `testing.TB` that returns a context bound to the current test's lifetime. The context becomes invalid _before_ `T.Cleanup` functions are run. *Details*: This change adds a similar `Context()` method to `rapid.T`, except this context is only valid for the duration of one iteration of a rapid check. *Implementation notes*: This changes `newT` to return a `cancel` function instead of just adding a `cancel` method to `T` to ensure that all callers of `newT` remember to call `cancel`. This also uses IIFEs (immediately-invoked function expressions) in a couple places to rely on well-timed `defer` calls for cleanup instead of manually calling `cancel`. *Future work*: The logic added in this commit will make it relatively straightforward to add a `Cleanup` method (#62). * lazy init, cleanup in checkOnce, maybeValue, example Per GitHub comment, delete the `cancel` return value from newT, instead add a single `cleanup` method. The method is called for cleanup in three places: - checkOnce: this is per property - maybeValue: this is per Custom generator function call - example: this is per Example call Context is now initialized lazily: if there isn't one, it is created. * fix: data race in t.ctx access
- Loading branch information
Showing
8 changed files
with
170 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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