Skip to content

Commit fa75bd5

Browse files
committed
Lower checks and steps 5x when -test.short flag is set
See #35
1 parent 110d7a5 commit fa75bd5

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

engine.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,17 @@ func MakeCheck(prop func(*T)) func(*testing.T) {
119119
func checkTB(tb tb, prop func(*T)) {
120120
tb.Helper()
121121

122+
checks := flags.checks
123+
if testing.Short() {
124+
checks /= 5
125+
}
126+
122127
start := time.Now()
123-
valid, invalid, seed, buf, err1, err2 := doCheck(tb, flags.failfile, flags.checks, baseSeed(), prop)
128+
valid, invalid, seed, buf, err1, err2 := doCheck(tb, flags.failfile, checks, baseSeed(), prop)
124129
dt := time.Since(start)
125130

126131
if err1 == nil && err2 == nil {
127-
if valid == flags.checks {
132+
if valid == checks {
128133
tb.Logf("[rapid] OK, passed %v tests (%v)", valid, dt)
129134
} else {
130135
tb.Errorf("[rapid] only generated %v valid tests from %v total (%v)", valid, valid+invalid, dt)

statemachine.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package rapid
99
import (
1010
"reflect"
1111
"sort"
12+
"testing"
1213
)
1314

1415
const (
@@ -56,10 +57,15 @@ type StateMachine interface {
5657
func Run(m StateMachine) func(*T) {
5758
typ := reflect.TypeOf(m)
5859

60+
steps := flags.steps
61+
if testing.Short() {
62+
steps /= 5
63+
}
64+
5965
return func(t *T) {
6066
t.Helper()
6167

62-
repeat := newRepeat(0, flags.steps, maxInt)
68+
repeat := newRepeat(0, steps, maxInt)
6369

6470
sm := newStateMachine(typ)
6571
if sm.init != nil {

0 commit comments

Comments
 (0)