aboutsummaryrefslogtreecommitdiff
path: root/core/testing/testing.odin
diff options
context:
space:
mode:
authorFeoramund <161657516+Feoramund@users.noreply.github.com>2024-05-29 18:04:59 -0400
committerFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-02 14:47:07 -0400
commit1f6a6f2cd367aec2e506ae8d5fafcb34d4b2a0e3 (patch)
treef7b377de19693f1ab649946f267c437e99ed59fe /core/testing/testing.odin
parenta27b16721893f78f1788c4f8a7a952d65f7799c3 (diff)
Support deterministic random seeding of tests
Add a new option `ODIN_TEST_RANDOM_SEED` which is picked from the cycle counter at startup, if it's not specified by the user. This number is sent to every test in the `T` struct and reset every test (just in case).
Diffstat (limited to 'core/testing/testing.odin')
-rw-r--r--core/testing/testing.odin10
1 files changed, 10 insertions, 0 deletions
diff --git a/core/testing/testing.odin b/core/testing/testing.odin
index 30109304d..92b4d391d 100644
--- a/core/testing/testing.odin
+++ b/core/testing/testing.odin
@@ -29,6 +29,16 @@ Internal_Cleanup :: struct {
T :: struct {
error_count: int,
+ // If your test needs to perform random operations, it's advised to use
+ // this value to seed a local random number generator rather than relying
+ // on the non-thread-safe global one.
+ //
+ // This way, your results will be deterministic.
+ //
+ // This value is chosen at startup of the test runner, logged, and may be
+ // specified by the user. It is the same for all tests of a single run.
+ seed: u64,
+
channel: Update_Channel_Sender,
cleanups: [dynamic]Internal_Cleanup,