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 ( import (
"flag" "flag"
"os"
"os/exec" "os/exec"
"path/filepath"
"testing" "testing"
cmdtest "github.com/google/go-cmdtest" cmdtest "github.com/google/go-cmdtest"
@ -38,10 +38,10 @@ func TestMain(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("read testdata: %v", err) 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) t.Fatal(err)
} }
defer os.Remove("pda") ts.Commands["pda"] = cmdtest.Program(bin)
ts.Commands["pda"] = cmdtest.Program("pda")
ts.Run(t, *update) ts.Run(t, *update)
} }