Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
42736: *: bump the `datadriven` dependency and update the calls r=knz a=knz

For use with cockroachdb/datadriven#7.

The `datadriven.RunTest` function uses sub-tests for each directive in
the input file. Since it's not valid to use `t.Fatal`, `t.Skip` etc on
a parent test while there is a sub-test `testing.T` active, the
`RunTest` interface has been updated so that the callback function
gets the sub-test as argument.

This patch bumps the dependency and updates the calls to `RunTest`
accordingly.

Release note: None

Co-authored-by: Raphael 'kena' Poss <[email protected]>
  • Loading branch information
craig[bot] and knz committed Nov 26, 2019
2 parents 78f8482 + 96910cd commit a7f0af0
Show file tree
Hide file tree
Showing 26 changed files with 41 additions and 41 deletions.
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/ccl/storageccl/engineccl/pebble_key_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func TestDataKeyManager(t *testing.T) {
}

datadriven.RunTest(t, "testdata/data_key_manager",
func(d *datadriven.TestData) string {
func(t *testing.T, d *datadriven.TestData) string {
switch d.Cmd {
case "init":
data := strings.Split(d.Input, "\n")
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/dump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestDumpData(t *testing.T) {
c.omitArgs = true
defer c.cleanup()

datadriven.RunTest(t, path, func(d *datadriven.TestData) string {
datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string {
args := []string{d.Cmd}
switch d.Cmd {
case "sql":
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/explain_tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestPlanToTreeAndPlanToString(t *testing.T) {
USE t;
`)

datadriven.RunTest(t, "testdata/explain_tree", func(d *datadriven.TestData) string {
datadriven.RunTest(t, "testdata/explain_tree", func(t *testing.T, d *datadriven.TestData) string {
switch d.Cmd {
case "exec":
r.Exec(t, d.Input)
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/idxconstraint/index_constraints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestIndexConstraints(t *testing.T) {
semaCtx := tree.MakeSemaContext()
evalCtx := tree.MakeTestingEvalContext(cluster.MakeTestingClusterSettings())

datadriven.RunTest(t, path, func(d *datadriven.TestData) string {
datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string {
var varTypes []*types.T
var indexCols []opt.OrderingColumn
var notNullCols opt.ColSet
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/memo/expr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestExprIsNeverNull(t *testing.T) {
datadriven.Walk(t, "testdata/expr", func(t *testing.T, path string) {
catalog := testcat.New()

datadriven.RunTest(t, path, func(d *datadriven.TestData) string {
datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string {
var varTypes []*types.T
var iVarHelper tree.IndexedVarHelper
var err error
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/memo/memo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func traverseExpr(expr memo.RelExpr, f func(memo.RelExpr)) {
func runDataDrivenTest(t *testing.T, path string, fmtFlags memo.ExprFmtFlags) {
datadriven.Walk(t, path, func(t *testing.T, path string) {
catalog := testcat.New()
datadriven.RunTest(t, path, func(d *datadriven.TestData) string {
datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string {
tester := opttester.New(catalog, d.Input)
tester.Flags.ExprFormat = fmtFlags
return tester.RunCommand(t, d)
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/norm/norm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestNormRules(t *testing.T) {
memo.ExprFmtHideQualifications | memo.ExprFmtHideScalars
datadriven.Walk(t, "testdata/rules", func(t *testing.T, path string) {
catalog := testcat.New()
datadriven.RunTest(t, path, func(d *datadriven.TestData) string {
datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string {
tester := opttester.New(catalog, d.Input)
tester.Flags.ExprFormat = fmtFlags
return tester.RunCommand(t, d)
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/optbuilder/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestBuilder(t *testing.T) {
datadriven.Walk(t, "testdata", func(t *testing.T, path string) {
catalog := testcat.New()

datadriven.RunTest(t, path, func(d *datadriven.TestData) string {
datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string {
var varTypes []*types.T
var iVarHelper tree.IndexedVarHelper
var err error
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/optgen/cmd/optgen/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestOptgen(t *testing.T) {

for _, path := range paths {
t.Run(filepath.Base(path), func(t *testing.T) {
datadriven.RunTest(t, path, func(d *datadriven.TestData) string {
datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string {
var buf bytes.Buffer

gen := optgen{useGoFmt: true, maxErrors: 2, stdErr: &buf}
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/optgen/exprgen/expr_gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
func TestExprGen(t *testing.T) {
datadriven.Walk(t, "testdata", func(t *testing.T, path string) {
catalog := testcat.New()
datadriven.RunTest(t, path, func(d *datadriven.TestData) string {
datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string {
tester := opttester.New(catalog, d.Input)
return tester.RunCommand(t, d)
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/optgen/lang/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

func TestCompiler(t *testing.T) {
datadriven.RunTest(t, "testdata/compiler", func(d *datadriven.TestData) string {
datadriven.RunTest(t, "testdata/compiler", func(t *testing.T, d *datadriven.TestData) string {
// Only compile command supported.
if d.Cmd != "compile" {
t.FailNow()
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/optgen/lang/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
)

func TestParser(t *testing.T) {
datadriven.RunTest(t, "testdata/parser", func(d *datadriven.TestData) string {
datadriven.RunTest(t, "testdata/parser", func(t *testing.T, d *datadriven.TestData) string {
// Only parse command supported.
if d.Cmd != "parse" {
t.FailNow()
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/optgen/lang/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
)

func TestScanner(t *testing.T) {
datadriven.RunTest(t, "testdata/scanner", func(d *datadriven.TestData) string {
datadriven.RunTest(t, "testdata/scanner", func(t *testing.T, d *datadriven.TestData) string {
// Only scan command supported.
if d.Cmd != "scan" {
t.FailNow()
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/opt/testutils/opttester/opt_tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -1069,9 +1069,9 @@ func (ot *OptTester) Import(tb testing.TB) {
tb.Fatalf("unable to find file %s", ot.Flags.File)
}
path := filepath.Join(filepath.Dir(optTesterFile), "testfixtures", ot.Flags.File)
datadriven.RunTest(tb.(*testing.T), path, func(d *datadriven.TestData) string {
datadriven.RunTest(tb.(*testing.T), path, func(t *testing.T, d *datadriven.TestData) string {
tester := New(ot.catalog, d.Input)
return tester.RunCommand(tb.(*testing.T), d)
return tester.RunCommand(t, d)
})
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/testutils/opttester/opt_tester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestOptTester(t *testing.T) {

datadriven.Walk(t, "testdata", func(t *testing.T, path string) {
catalog := testcat.New()
datadriven.RunTest(t, path, func(d *datadriven.TestData) string {
datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string {
tester := opttester.New(catalog, d.Input)
tester.Flags.ExprFormat = fmtFlags
return tester.RunCommand(t, d)
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/testutils/testcat/test_catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestCatalog(t *testing.T) {
datadriven.Walk(t, "testdata", func(t *testing.T, path string) {
catalog := testcat.New()

datadriven.RunTest(t, path, func(d *datadriven.TestData) string {
datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string {
tester := opttester.New(catalog, d.Input)
return tester.RunCommand(t, d)
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/opt/xform/optimizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func TestRuleProps(t *testing.T) {
defer leaktest.AfterTest(t)()
datadriven.Walk(t, "testdata/ruleprops", func(t *testing.T, path string) {
catalog := testcat.New()
datadriven.RunTest(t, path, func(d *datadriven.TestData) string {
datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string {
tester := opttester.New(catalog, d.Input)
tester.Flags.ExprFormat = memo.ExprFmtHideStats | memo.ExprFmtHideCost |
memo.ExprFmtHideQualifications | memo.ExprFmtHideScalars
Expand Down Expand Up @@ -222,7 +222,7 @@ func TestExternal(t *testing.T) {
func runDataDrivenTest(t *testing.T, path string, fmtFlags memo.ExprFmtFlags) {
datadriven.Walk(t, path, func(t *testing.T, path string) {
catalog := testcat.New()
datadriven.RunTest(t, path, func(d *datadriven.TestData) string {
datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string {
tester := opttester.New(catalog, d.Input)
tester.Flags.ExprFormat = fmtFlags
return tester.RunCommand(t, d)
Expand Down
15 changes: 8 additions & 7 deletions pkg/sql/pgwire/hba/hba_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ import (
)

func TestParse(t *testing.T) {
datadriven.RunTest(t, filepath.Join("testdata", "parse"), func(d *datadriven.TestData) string {
conf, err := Parse(d.Input)
if err != nil {
return fmt.Sprintf("error: %v\n", err)
}
return conf.String()
})
datadriven.RunTest(t, filepath.Join("testdata", "parse"),
func(t *testing.T, d *datadriven.TestData) string {
conf, err := Parse(d.Input)
if err != nil {
return fmt.Sprintf("error: %v\n", err)
}
return conf.String()
})
}

// TODO(mjibson): these are untested outside ccl +gss builds.
Expand Down
12 changes: 6 additions & 6 deletions pkg/sql/sem/tree/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ func TestEval(t *testing.T) {
evalCtx := tree.NewTestingEvalContext(cluster.MakeTestingClusterSettings())
defer evalCtx.Stop(ctx)

walk := func(t *testing.T, getExpr func(*datadriven.TestData) string) {
walk := func(t *testing.T, getExpr func(*testing.T, *datadriven.TestData) string) {
datadriven.Walk(t, filepath.Join("testdata", "eval"), func(t *testing.T, path string) {
datadriven.RunTest(t, path, func(d *datadriven.TestData) string {
datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string {
if d.Cmd != "eval" {
t.Fatalf("unsupported command %s", d.Cmd)
}
return getExpr(d) + "\n"
return getExpr(t, d) + "\n"
})
})
}

walkExpr := func(t *testing.T, getExpr func(tree.TypedExpr) (tree.TypedExpr, error)) {
walk(t, func(d *datadriven.TestData) string {
walk(t, func(t *testing.T, d *datadriven.TestData) string {
expr, err := parser.ParseExpr(d.Input)
if err != nil {
t.Fatalf("%s: %v", d.Input, err)
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestEval(t *testing.T) {
s, sqlDB, _ := serverutils.StartServer(t, base.TestServerArgs{})
defer s.Stopper().Stop(ctx)

walk(t, func(d *datadriven.TestData) string {
walk(t, func(t *testing.T, d *datadriven.TestData) string {
var res gosql.NullString
if err := sqlDB.QueryRow(fmt.Sprintf("SELECT (%s)::STRING", d.Input)).Scan(&res); err != nil {
return strings.TrimPrefix(err.Error(), "pq: ")
Expand Down Expand Up @@ -165,7 +165,7 @@ func TestEval(t *testing.T) {
})

t.Run("vectorized", func(t *testing.T) {
walk(t, func(d *datadriven.TestData) string {
walk(t, func(t *testing.T, d *datadriven.TestData) string {
if d.Input == "B'11111111111111111111111110000101'::int4" {
// Skip this test: https://github.com/cockroachdb/cockroach/pull/40790#issuecomment-532597294.
return strings.TrimSpace(d.Expected)
Expand Down
3 changes: 1 addition & 2 deletions pkg/storage/engine/disk_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ func (r *rocksDBMap) put(k []byte, v []byte) error {
func runTestForEngine(ctx context.Context, t *testing.T, filename string, engine diskmap.Factory) {
diskMaps := make(map[string]diskmap.SortedDiskMap)

datadriven.RunTest(t, filename, func(d *datadriven.TestData) string {

datadriven.RunTest(t, filename, func(t *testing.T, d *datadriven.TestData) string {
if d.Cmd == "raw-count" {
var keyCount int
// Trying to build a common interface to RocksDB and Pebble's iterator
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/engine/pebble_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
func TestPebbleTimeBoundPropCollector(t *testing.T) {
defer leaktest.AfterTest(t)()

datadriven.RunTest(t, "testdata/time_bound_props", func(d *datadriven.TestData) string {
datadriven.RunTest(t, "testdata/time_bound_props", func(t *testing.T, d *datadriven.TestData) string {
c := &pebbleTimeBoundPropCollector{}
switch d.Cmd {
case "build":
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/replica_raft_truncation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestHandleTruncatedStateBelowRaft(t *testing.T) {
eng := engine.NewDefaultInMem()
defer eng.Close()

datadriven.RunTest(t, path, func(d *datadriven.TestData) string {
datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string {
switch d.Cmd {
case "prev":
d.ScanArgs(t, "index", &prevTruncatedState.Index)
Expand Down
2 changes: 1 addition & 1 deletion pkg/testutils/pgtest/datadriven.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func RunTest(t *testing.T, path, addr, user string) {
if err != nil {
t.Fatal(err)
}
datadriven.RunTest(t, path, func(d *datadriven.TestData) string {
datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string {
switch d.Cmd {
case "send":
for _, line := range strings.Split(d.Input, "\n") {
Expand Down
2 changes: 1 addition & 1 deletion pkg/testutils/reduce/datadriven.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func RunTest(
if testing.Verbose() {
log = os.Stderr
}
datadriven.RunTest(t, path, func(d *datadriven.TestData) string {
datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string {
switch d.Cmd {
case "contains":
contains = d.Input
Expand Down
2 changes: 1 addition & 1 deletion vendor

0 comments on commit a7f0af0

Please sign in to comment.