Skip to content

Commit

Permalink
bazel: make pkg/internal/rsg/yacc test runnable in Bazel
Browse files Browse the repository at this point in the history
This test was missing a dependency on `sql.y`.

Release note: None
  • Loading branch information
rickystewart committed Mar 10, 2021
1 parent 4d2d303 commit 3457f76
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
7 changes: 5 additions & 2 deletions pkg/internal/rsg/yacc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ go_test(
name = "yacc_test",
size = "small",
srcs = ["parse_test.go"],
data = ["//pkg/sql/parser:sql.y"],
embed = [":yacc"],
tags = ["broken_in_bazel"],
deps = ["//pkg/util/log"],
deps = [
"//pkg/build/bazel",
"//pkg/util/log",
],
)
15 changes: 14 additions & 1 deletion pkg/internal/rsg/yacc/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,24 @@ import (
"io/ioutil"
"testing"

"github.com/cockroachdb/cockroach/pkg/build/bazel"
// Needed for the -verbosity flag on circleci tests.
_ "github.com/cockroachdb/cockroach/pkg/util/log"
)

const sqlYPath = "../../../sql/parser/sql.y"
var sqlYPath string

func init() {
if bazel.BuiltWithBazel() {
runfile, err := bazel.Runfile("pkg/sql/parser/sql.y")
if err != nil {
panic(err)
}
sqlYPath = runfile
} else {
sqlYPath = "../../../sql/parser/sql.y"
}
}

func TestLex(t *testing.T) {
b, err := ioutil.ReadFile(sqlYPath)
Expand Down

0 comments on commit 3457f76

Please sign in to comment.