From 21a29bcda577d7b66a9ce6eb68563b3e150370f3 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Sun, 2 Nov 2025 09:22:28 -0800 Subject: [PATCH] Fix TestScripts failures - add bd binary to PATH TestScripts was failing with 'exit status 127' because test scripts use 'exec sh -c bd ...' which spawns a shell subprocess that doesn't have access to the script engine's registered bd command. Solution: Add the temp directory containing the built bd binary to the PATH environment variable when running tests, so shell subprocesses can find the bd executable. This fixes the last remaining CI failures. Amp-Thread-ID: https://ampcode.com/threads/T-63ef3a7d-8efe-472d-97ed-6ac95bd8318b Co-authored-by: Amp --- cmd/bd/scripttest_test.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/bd/scripttest_test.go b/cmd/bd/scripttest_test.go index 989b8065..dd44d391 100644 --- a/cmd/bd/scripttest_test.go +++ b/cmd/bd/scripttest_test.go @@ -2,6 +2,7 @@ package main import ( "context" + "os" "os/exec" "path/filepath" "runtime" @@ -20,7 +21,8 @@ func TestScripts(t *testing.T) { // Build the bd binary exeName := "bd" - exe := filepath.Join(t.TempDir(), exeName) + binDir := t.TempDir() + exe := filepath.Join(binDir, exeName) if err := exec.Command("go", "build", "-o", exe, ".").Run(); err != nil { t.Fatal(err) } @@ -29,7 +31,11 @@ func TestScripts(t *testing.T) { timeout := 2 * time.Second engine := script.NewEngine() engine.Cmds["bd"] = script.Program(exe, nil, timeout) - + + // Add binDir to PATH so 'sh -c bd ...' works in test scripts + currentPath := os.Getenv("PATH") + env := []string{"PATH=" + binDir + ":" + currentPath} + // Run all tests - scripttest.Test(t, context.Background(), engine, nil, "testdata/*.txt") + scripttest.Test(t, context.Background(), engine, env, "testdata/*.txt") }