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: make pkg/internal/rsg/yacc test runnable in Bazel #61796

Merged
merged 1 commit into from
Mar 10, 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
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