From 3457f760c496449016be8655524ec86f23e5be40 Mon Sep 17 00:00:00 2001 From: Ricky Stewart Date: Wed, 10 Mar 2021 14:10:24 -0600 Subject: [PATCH] bazel: make `pkg/internal/rsg/yacc` test runnable in Bazel This test was missing a dependency on `sql.y`. Release note: None --- pkg/internal/rsg/yacc/BUILD.bazel | 7 +++++-- pkg/internal/rsg/yacc/parse_test.go | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/pkg/internal/rsg/yacc/BUILD.bazel b/pkg/internal/rsg/yacc/BUILD.bazel index fb3b95cf1db8..e3cdbc0572a7 100644 --- a/pkg/internal/rsg/yacc/BUILD.bazel +++ b/pkg/internal/rsg/yacc/BUILD.bazel @@ -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", + ], ) diff --git a/pkg/internal/rsg/yacc/parse_test.go b/pkg/internal/rsg/yacc/parse_test.go index cd4ddf568d20..c53087451c85 100644 --- a/pkg/internal/rsg/yacc/parse_test.go +++ b/pkg/internal/rsg/yacc/parse_test.go @@ -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)