Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.2k
expose random seed to the test runner #17609
Copy link
Copy link
Closed
Labels
acceptedThis proposal is planned.This proposal is planned.enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.proposalThis issue suggests language modifications. If it also has the "accepted" label then it is planned.This issue suggests language modifications. If it also has the "accepted" label then it is planned.standard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Milestone
Description
Metadata
Metadata
Assignees
Labels
acceptedThis proposal is planned.This proposal is planned.enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.proposalThis issue suggests language modifications. If it also has the "accepted" label then it is planned.This issue suggests language modifications. If it also has the "accepted" label then it is planned.standard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
In #14940, the Zig compiler passes a 32-bit integer
--seedparameter to the build runner for shuffling dependency traversal order. If something goes wrong, the user can repeat the same operation with the same seed because the seed will be printed on the command line.This same concept can be useful for unit tests which want to use randomness but also need reproducibility.
This proposal is to expose the seed to std.testing so that unit tests can obtain it and use it.
This would also provide a way to resolve one area of confusion for users which is the fact that unit tests get cached. Some users are confused why unit tests would be cached. Explicitly having this seed would make everything make sense. If you give the same seed, then the test runs are considered cached. If you give a different seed, it's a new run.
Example code:
If this is implemented then it will be important for the seed to be displayed if the tests fail. This is already the case, as shown here:
This proposal would mean that last line would include, for example,
--seed 0xdeadbeef.