From 29f793aca83c33f4dce01105c1600e24416a38b9 Mon Sep 17 00:00:00 2001 From: James Munnelly Date: Thu, 6 Jan 2022 16:50:44 +0000 Subject: [PATCH] Prefer RUNFILES_DIR if it is set Signed-off-by: James Munnelly --- internal/test/paths/bazel.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/internal/test/paths/bazel.go b/internal/test/paths/bazel.go index 2567debe5..c8138020a 100644 --- a/internal/test/paths/bazel.go +++ b/internal/test/paths/bazel.go @@ -41,17 +41,15 @@ func PathForCRD(t *testing.T, name string) string { } func CRDDirectory(t *testing.T) string { - runfiles := os.Getenv("RUNFILES_DIR") bazelDir := BazelBinDir - if runfiles == "" && bazelDir == "" { - t.Fatalf("integration tests can only run within 'bazel test' environment or have BAZEL_BIN_DIR set") - } - var path string - if bazelDir != "" { - path = filepath.Join(bazelDir, "deploy", "crds") - } else { + path := filepath.Join(bazelDir, "deploy", "crds") + + // prefer RUNFILES_DIR if set + runfiles := os.Getenv("RUNFILES_DIR") + if runfiles != "" { path = filepath.Join(runfiles, "com_github_jetstack_cert_manager", "deploy", "crds") } + info, err := os.Stat(path) if err != nil { t.Fatal(err)