From cffc2c2f814a59255dc54c710af853f599edb724 Mon Sep 17 00:00:00 2001 From: Andrew Z Allen Date: Sun, 24 Feb 2019 15:53:10 -0700 Subject: [PATCH] Fix windows tests --- gazelle/fileinfo_test.go | 5 ++++- gazelle/parser/BUILD.bazel | 6 ++++-- gazelle/parser/tokenizer_test.go | 9 ++++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/gazelle/fileinfo_test.go b/gazelle/fileinfo_test.go index 11ed60d..9470fa8 100644 --- a/gazelle/fileinfo_test.go +++ b/gazelle/fileinfo_test.go @@ -23,7 +23,10 @@ import ( "testing" ) -func TestProtoFileInfo(t *testing.T) { +// TestFileInfo tests that when a FileInfo object is constructed from the +// provided input of the `sass` parameter, the output contains the correct +// set of imports. +func TestFileInfo(t *testing.T) { for _, tc := range []struct { desc, name, sass string want FileInfo diff --git a/gazelle/parser/BUILD.bazel b/gazelle/parser/BUILD.bazel index e07142f..5880f94 100644 --- a/gazelle/parser/BUILD.bazel +++ b/gazelle/parser/BUILD.bazel @@ -25,8 +25,10 @@ go_test( srcs = ["tokenizer_test.go"], data = [":testdata"], embed = [":go_default_library"], - rundir = "gazelle/parser", - deps = ["@com_github_google_go_cmp//cmp:go_default_library"], + deps = [ + "@com_github_google_go_cmp//cmp:go_default_library", + "@io_bazel_rules_go//go/tools/bazel:go_default_library", + ], ) filegroup( diff --git a/gazelle/parser/tokenizer_test.go b/gazelle/parser/tokenizer_test.go index 6024ade..fa1dfcc 100644 --- a/gazelle/parser/tokenizer_test.go +++ b/gazelle/parser/tokenizer_test.go @@ -9,6 +9,7 @@ import ( "strings" "testing" + "github.com/bazelbuild/rules_go/go/tools/bazel" "github.com/google/go-cmp/cmp" ) @@ -617,7 +618,13 @@ func TestScanNumber(t *testing.T) { func TestLargeInputs(t *testing.T) { found := false - if err := filepath.Walk("testdata", func(path string, info os.FileInfo, err error) error { + + testDataDir, err := bazel.Runfile(filepath.Join("gazelle", "parser", "testdata")) + if err != nil { + t.Fatalf("Error finding runfile gazelle/parser/testdata: %s", err) + } + + if err := filepath.Walk(testDataDir, func(path string, info os.FileInfo, err error) error { // Don't parse the root, or directories. if info == nil || info.IsDir() { return nil