Skip to content

Commit

Permalink
sqlsmith: allow tests to turn off mutations and WITHs
Browse files Browse the repository at this point in the history
  • Loading branch information
maddyblue committed May 14, 2019
1 parent 33f609e commit a33a5cc
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/internal/sqlsmith/sqlsmith_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ import (
)

var (
flagExec = flag.Bool("ex", false, "execute (instead of just parse) generated statements")
flagNum = flag.Int("num", 100, "number of statements to generate")
flagExec = flag.Bool("ex", false, "execute (instead of just parse) generated statements")
flagNum = flag.Int("num", 100, "number of statements to generate")
flagNoMutations = flag.Bool("no-mutations", false, "disables mutations during testing")
flagNoWiths = flag.Bool("no-withs", false, "disables WITHs during testing")
)

func init() {
Expand Down Expand Up @@ -73,7 +75,15 @@ func TestGenerateParse(t *testing.T) {
INSERT INTO t DEFAULT VALUES;
`)

smither, err := NewSmither(sqlDB, rnd)
var opts []SmitherOption
if *flagNoMutations {
opts = append(opts, DisableMutations())
}
if *flagNoWiths {
opts = append(opts, DisableWith())
}

smither, err := NewSmither(nil, rnd, opts...)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit a33a5cc

Please sign in to comment.