Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions internal/cli/hook_prompt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,21 @@ func writePromptTranscript(t *testing.T, path, text string) {
}
}
func TestPermissionHookBuiltBinary(t *testing.T) {
// readEnv moves HOME to a temporary directory. Build with the real Go
// caches: with GOPATH unset, go would otherwise fill a module cache under
// that HOME with read-only files the test cannot remove.
caches, err := exec.Command("go", "env", "GOMODCACHE", "GOCACHE").Output()
if err != nil {
t.Fatal(err)
}
modCache, buildCache, _ := strings.Cut(strings.TrimSpace(string(caches)), "\n")
readEnv(t)
bin := filepath.Join(t.TempDir(), "driga")
if runtime.GOOS == "windows" {
bin += ".exe"
}
build := exec.Command("go", "build", "-o", bin, "../../cmd/driga")
build.Env = append(os.Environ(), "GOMODCACHE="+strings.TrimSpace(modCache), "GOCACHE="+strings.TrimSpace(buildCache))
if out, err := build.CombinedOutput(); err != nil {
t.Fatalf("build: %v: %s", err, out)
}
Expand Down
Loading