Skip to content

Commit

Permalink
internal/keyspan: remove datadriven runtime dep
Browse files Browse the repository at this point in the history
In #3293 some helpers were exported for reuse in other tests and
the file suffix of _test was removed, however this meant that the
keyspan package started to link in datadriven even in non-test
binaries. This is not desired, as datadriven has init-registered
flags such as rewrite and should only be linked in test binaries.

Fortunately the helpers only needed a string field so we don't need
to use 'datadriven' to pass it that.
  • Loading branch information
dt committed Feb 21, 2024
1 parent 9e60abf commit ccb837b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/keyspan/bounded_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestBoundedIter(t *testing.T) {
buf.Reset()
lower, upper := getBounds(td)
iter.SetBounds(lower, upper)
RunIterCmd(td, &iter, &buf)
RunIterCmd(td.Input, &iter, &buf)
return buf.String()
default:
return fmt.Sprintf("unrecognized command %q", td.Cmd)
Expand Down
2 changes: 1 addition & 1 deletion internal/keyspan/keyspanimpl/merging_iter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestMergingIter(t *testing.T) {
}
var iter MergingIter
iter.Init(cmp, keyspan.VisibleTransform(snapshot), new(MergingBuffers), iters...)
keyspan.RunIterCmd(td, &iter, &buf)
keyspan.RunIterCmd(td.Input, &iter, &buf)
return buf.String()
default:
return fmt.Sprintf("unrecognized command %q", td.Cmd)
Expand Down
5 changes: 2 additions & 3 deletions internal/keyspan/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"strconv"
"strings"

"github.com/cockroachdb/datadriven"
"github.com/cockroachdb/errors"
"github.com/cockroachdb/pebble/internal/dsl"
)
Expand Down Expand Up @@ -381,8 +380,8 @@ func (p *probeIterator) WrapChildren(wrap WrapFn) {
// RunIterCmd evaluates a datadriven command controlling an internal
// keyspan.FragmentIterator, writing the results of the iterator operations to
// the provided writer.
func RunIterCmd(td *datadriven.TestData, iter FragmentIterator, w io.Writer) {
lines := strings.Split(strings.TrimSpace(td.Input), "\n")
func RunIterCmd(tdInput string, iter FragmentIterator, w io.Writer) {
lines := strings.Split(strings.TrimSpace(tdInput), "\n")
for i, line := range lines {
if i > 0 {
fmt.Fprintln(w)
Expand Down
2 changes: 1 addition & 1 deletion internal/keyspan/truncate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestTruncate(t *testing.T) {

case "saved-iter":
var buf bytes.Buffer
RunIterCmd(d, savedIter, &buf)
RunIterCmd(d.Input, savedIter, &buf)
return buf.String()

default:
Expand Down

0 comments on commit ccb837b

Please sign in to comment.