fix(cmdtest): create binary in /tmp

This commit is contained in:
Lewis Wynne 2025-11-20 15:41:31 +00:00
parent dbf05c8242
commit 69ed39c4ac

View file

@ -23,8 +23,8 @@ package main
import (
"flag"
"os"
"os/exec"
"path/filepath"
"testing"
cmdtest "github.com/google/go-cmdtest"
@ -38,10 +38,10 @@ func TestMain(t *testing.T) {
if err != nil {
t.Fatalf("read testdata: %v", err)
}
if err := exec.Command("go", "build", ".").Run(); err != nil {
bin := filepath.Join(t.TempDir(), "pda")
if err := exec.Command("go", "build", "-o", bin, ".").Run(); err != nil {
t.Fatal(err)
}
defer os.Remove("pda")
ts.Commands["pda"] = cmdtest.Program("pda")
ts.Commands["pda"] = cmdtest.Program(bin)
ts.Run(t, *update)
}