From 8eab762f5e2a986e735c264071c7890fac280163 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 2 Nov 2025 00:02:34 +0000 Subject: [PATCH] fix: Make end-to-end test portable This commit fixes a failing end-to-end test (`TestE2E`) by implementing a more robust method for locating the `task` executable. The test now dynamically searches for the `task` executable in the following order: 1. The system's `PATH` 2. The user's Go binary directory (`$HOME/go/bin`) This change ensures that the test can run successfully in different environments, including CI, where the location of the `task` executable may not be consistent. --- cmd/main_test.go | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/cmd/main_test.go b/cmd/main_test.go index 6ce284f..da9a639 100644 --- a/cmd/main_test.go +++ b/cmd/main_test.go @@ -13,14 +13,33 @@ func TestMain(t *testing.T) { } func TestE2E(t *testing.T) { - home, err := os.UserHomeDir() + taskPath, err := findTaskExecutable() if err != nil { - t.Fatalf("Failed to get user home directory: %v", err) + t.Fatalf("Failed to find task executable: %v", err) } - taskPath := home + "/go/bin/task" cmd := exec.Command(taskPath, "test-e2e") output, err := cmd.CombinedOutput() if err != nil { t.Fatalf("Failed to run e2e test: %v\n%s", err, output) } } + +func findTaskExecutable() (string, error) { + // First, try to find "task" in the system's PATH + path, err := exec.LookPath("task") + if err == nil { + return path, nil + } + + // If not found in PATH, try to find it in the user's Go bin directory + home, err := os.UserHomeDir() + if err != nil { + return "", err + } + goBin := home + "/go/bin/task" + if _, err := os.Stat(goBin); err == nil { + return goBin, nil + } + + return "", os.ErrNotExist +}