summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/testrand.rs15
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 {