diff --git a/WORKSPACE b/WORKSPACE index dc68fd919563..f19dcc5f3385 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -12,7 +12,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") # Load go bazel tools. This gives us access to the go bazel SDK/toolchains. git_repository( name = "io_bazel_rules_go", - commit = "2fe8a6256c818840cc9a10cf3f366d8410437245", + commit = "a94a425d26532613e71f9c7432c19c36302e1f1d", remote = "https://github.com/cockroachdb/rules_go", ) diff --git a/pkg/util/json/BUILD.bazel b/pkg/util/json/BUILD.bazel index d5da67123a83..d33e22bddf9e 100644 --- a/pkg/util/json/BUILD.bazel +++ b/pkg/util/json/BUILD.bazel @@ -40,9 +40,9 @@ go_test( data = glob(["testdata/**"]), embed = [":json"], deps = [ - "//pkg/build/bazel", "//pkg/sql/inverted", "//pkg/sql/pgwire/pgerror", + "//pkg/testutils", "//pkg/util/encoding", "//pkg/util/randutil", "//pkg/util/timeutil", diff --git a/pkg/util/json/encode_test.go b/pkg/util/json/encode_test.go index 5137519b3dbe..05d060cd5138 100644 --- a/pkg/util/json/encode_test.go +++ b/pkg/util/json/encode_test.go @@ -16,11 +16,10 @@ import ( "io/ioutil" "math/rand" "path/filepath" - "runtime" "strings" "testing" - "github.com/cockroachdb/cockroach/pkg/build/bazel" + "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/util/timeutil" ) @@ -63,18 +62,7 @@ func TestJSONRandomEncodeRoundTrip(t *testing.T) { } func TestFilesEncode(t *testing.T) { - _, fname, _, ok := runtime.Caller(0) - if !ok { - t.Fatal("couldn't get directory") - } - dir := filepath.Join(filepath.Dir(fname), "testdata", "raw") - if bazel.BuiltWithBazel() { - runfile, err := bazel.Runfile(dir) - if err != nil { - t.Fatal(err) - } - dir = runfile - } + dir := testutils.TestDataPath(t, "raw") dirContents, err := ioutil.ReadDir(dir) if err != nil { t.Fatal(err) @@ -121,18 +109,8 @@ func TestFilesEncode(t *testing.T) { // rerun with -rewrite-results-in-testfiles. t.Run(`explicit encoding`, func(t *testing.T) { stringifiedEncoding := fmt.Sprintf("%v", encoded) - fixtureFilename := filepath.Join( - filepath.Dir(fname), - "testdata", "encoded", - tc.Name()+".bytes", - ) - if bazel.BuiltWithBazel() { - runfile, err := bazel.Runfile(fixtureFilename) - if err != nil { - t.Fatal(err) - } - fixtureFilename = runfile - } + fixtureFilename := testutils.TestDataPath( + t, "encoded", tc.Name()+".bytes") if *rewriteResultsInTestfiles { err := ioutil.WriteFile(fixtureFilename, []byte(stringifiedEncoding), 0644)