diff options
| author | tv <tv@krebsco.de> | 2026-10-25 23:28:21 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-25 23:28:21 +0100 |
| commit | 9dfe4769bf2ee002353c9db3c9b9dfb9701139dc (patch) | |
| tree | 46e5c2cdd8ed3ce95ed271735f37fdebc05fe884 /src/testrand.rs | |
| parent | f8071dc92c858186d9fe1c4b7b430d26030018ab (diff) | |
make test RNG configurable via env
Diffstat (limited to 'src/testrand.rs')
| -rw-r--r-- | src/testrand.rs | 15 |
1 files changed, 12 insertions, 3 deletions
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::<u64>().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 { |
