Documentation
¶
Overview ¶
Package testbin builds the executables that test harnesses run as child processes, and keeps every such executable and every `go` build temporary on disk, outside the test process's TMPDIR and GOTMPDIR.
Why ¶
Tests may run with TMPDIR and GOTMPDIR pointed at a RAM drive that must hold graph data files only (see CLAUDE.md, "Tests and validation"). A harness that builds a child binary with os.MkdirTemp("", …) and an inherited environment writes the binary, and the child `go` command's work directory, to that RAM drive. This package is the single seam that prevents it:
- MkdirTemp and TempDir create directories under Root, a fixed location in the user cache directory, never under TMPDIR or GOTMPDIR.
- Go runs the `go` command with TMPDIR and GOTMPDIR reset, in the child's environment only, to a fresh directory under Root that it removes before returning.
Ownership ¶
The caller owns every directory MkdirTemp returns and must remove it. TempDir registers that removal with the test's Cleanup. A process killed before its cleanup runs leaves its directory under Root.
Concurrency ¶
Every function is safe for concurrent use by multiple goroutines and by multiple processes: each call creates its own uniquely named directory and shares no mutable state.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Go ¶
Go runs `go args...` with working directory dir and returns its standard output and standard error. The child inherits the current environment except TMPDIR and GOTMPDIR, which point to a fresh directory under Root that Go removes before returning, so the `go` command's work files never reach the caller's TMPDIR or GOTMPDIR. The command is killed when ctx is done.
func MkdirTemp ¶
MkdirTemp creates a new, uniquely named directory under Root, with pattern interpreted as by os.MkdirTemp, and returns its path. The caller owns the directory and must remove it.