From 9dfe4769bf2ee002353c9db3c9b9dfb9701139dc Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 25 Oct 2026 23:28:21 +0100 Subject: make test RNG configurable via env --- src/testrand.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/testrand.rs') diff --git a/src/testrand.rs b/src/testrand.rs index dbb2148..56a063d 100644 --- a/src/testrand.rs +++ b/src/testrand.rs @@ -68,10 +68,19 @@ impl Rng { } } -/// Runs `check` once per seed in `0..cases`, each with its own generator. A failing case -/// says its seed, to rerun it alone with `Rng::new(seed)`. +/// Runs `check` once per seed, each with its own generator: seeds `0..cases` by default, +/// so every run checks the same cases. To explore further, `CONTINUUM_TEST_SEED` moves +/// the first seed and `CONTINUUM_TEST_CASES` multiplies the number of cases. A failing +/// case says its seed, to rerun it alone with `Rng::new(seed)`. pub(crate) fn for_seeds(cases: u64, check: impl Fn(&mut Rng)) { - for seed in 0..cases { + let env = |name: &str| { + std::env::var(name) + .ok() + .and_then(|value| value.parse::().ok()) + }; + let first = env("CONTINUUM_TEST_SEED").unwrap_or(0); + let cases = cases.saturating_mul(env("CONTINUUM_TEST_CASES").unwrap_or(1)); + for seed in first..first.saturating_add(cases) { let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| check(&mut Rng::new(seed)))); if let Err(panic) = result { -- cgit v1.3.1