Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bazel: stage all go source files in a temp dir named after the package #65094

Merged
merged 1 commit into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/util/json/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
30 changes: 4 additions & 26 deletions pkg/util/json/encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down