Skip to content

Commit

Permalink
Lower checks and steps 5x when -test.short flag is set
Browse files Browse the repository at this point in the history
See #35
  • Loading branch information
flyingmutant committed Aug 24, 2022
1 parent 110d7a5 commit fa75bd5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 7 additions & 2 deletions engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,17 @@ func MakeCheck(prop func(*T)) func(*testing.T) {
func checkTB(tb tb, prop func(*T)) {
tb.Helper()

checks := flags.checks
if testing.Short() {
checks /= 5
}

start := time.Now()
valid, invalid, seed, buf, err1, err2 := doCheck(tb, flags.failfile, flags.checks, baseSeed(), prop)
valid, invalid, seed, buf, err1, err2 := doCheck(tb, flags.failfile, checks, baseSeed(), prop)
dt := time.Since(start)

if err1 == nil && err2 == nil {
if valid == flags.checks {
if valid == checks {
tb.Logf("[rapid] OK, passed %v tests (%v)", valid, dt)
} else {
tb.Errorf("[rapid] only generated %v valid tests from %v total (%v)", valid, valid+invalid, dt)
Expand Down
8 changes: 7 additions & 1 deletion statemachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package rapid
import (
"reflect"
"sort"
"testing"
)

const (
Expand Down Expand Up @@ -56,10 +57,15 @@ type StateMachine interface {
func Run(m StateMachine) func(*T) {
typ := reflect.TypeOf(m)

steps := flags.steps
if testing.Short() {
steps /= 5
}

return func(t *T) {
t.Helper()

repeat := newRepeat(0, flags.steps, maxInt)
repeat := newRepeat(0, steps, maxInt)

sm := newStateMachine(typ)
if sm.init != nil {
Expand Down

0 comments on commit fa75bd5

Please sign in to comment.