From e0500ebb8793c84408646a2c01a521dae3d7c8bd Mon Sep 17 00:00:00 2001 From: Gregory Petrosyan Date: Sun, 11 Jun 2023 01:00:19 +0300 Subject: [PATCH] Make Run() execute a variable number of actions --- engine.go | 2 +- statemachine.go | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/engine.go b/engine.go index d35ed3c..2db1b6e 100644 --- a/engine.go +++ b/engine.go @@ -59,7 +59,7 @@ type cmdline struct { func init() { flag.IntVar(&flags.checks, "rapid.checks", 100, "rapid: number of checks to perform") - flag.IntVar(&flags.steps, "rapid.steps", 100, "rapid: number of state machine steps to perform") + flag.IntVar(&flags.steps, "rapid.steps", 30, "rapid: average number of Run actions to execute") flag.StringVar(&flags.failfile, "rapid.failfile", "", "rapid: fail file to use to reproduce test failure") flag.BoolVar(&flags.nofailfile, "rapid.nofailfile", false, "rapid: do not write fail files on test failures") flag.Uint64Var(&flags.seed, "rapid.seed", 0, "rapid: PRNG seed to start with (0 to use a random one)") diff --git a/statemachine.go b/statemachine.go index 503d9e5..95c73e6 100644 --- a/statemachine.go +++ b/statemachine.go @@ -7,7 +7,6 @@ package rapid import ( - "math" "reflect" "sort" "testing" @@ -46,10 +45,10 @@ func (t *T) Run(actions map[string]func(*T)) { steps := flags.steps if testing.Short() { - steps /= 5 + steps /= 2 } - repeat := newRepeat(0, steps, math.MaxInt, "Run") + repeat := newRepeat(-1, -1, float64(steps), "Run") sm := stateMachine{ check: check, actionKeys: SampledFrom(actionKeys),