Running Tests¶
Quality gates¶
cd daemon-go
gofmt -w .
go vet ./...
go test -race ./...
cd ../web
npm test -- --run
npm run build
cd ../daemon-go/cli/assets/channel # the experimental channel client
bun install --frozen-lockfile
bun test
CI runs the same core gates, and typechecks the channel's shipped sources (server.ts, daemon-session.ts).
Notes¶
- Route and WebSocket tests use
httptestplus the native WebSocket client. - SQLite fixtures must stop request/worker producers and release rows, transactions, and borrowed connections before
Store.Close, then remove their temporary directory.Store.Closejoins physical SQLite connection opens and closes, including replacement opens whose requesting query was already cancelled; concurrent callers receive the same completed shutdown result. Raw read-only pools have a single close owner. Test this ordering with barriers rather than cleanup retries or sleeps. The lifecycle regression demonstrates a pool shutdown race; it does not establish the natural cause of every #839 CI failure. - Keep environment-sensitive runtime detection tests hermetic.
- Rebuild and re-run setup after hook changes because hooks run from the recorded binary.
- A test that needs tmux gets its own server from
internal/tmuxtest, never by callingtmuxitself. Tests run inside tmux panes, and a baretmux(including a cleanup'skill-server) reaches the server named in$TMUX: the live one running your agents.tmuxtest.Newnames a private socket with-S, puts a shim first onPATHso the code under test reaches only that socket, refuses a socket that is the live server's, and stops the server only while its socket exists.tmuxtest.FollowEnv()is for code whose subject is how tmux reads$TMUX(hooks): the environment then points at the sandbox instead of a shim. On a host that cannot run a tmux server (an agent sandbox that denies the socket or a pane's terminal), these tests skip with tmux's diagnostic instead of failing. Every package whose tests reach code that runs tmux (main,cli,codexbridge,hooks,hub,mcpstdio,relayserver,service) also has aTestMaincallingtmuxtest.Main: it clearsTMUXand pointsTMUX_TMPDIRat an empty private directory for the whole test binary, so even an indirecttmuxcall finds no server rather than the live one. A new package that reaches tmux needs the sameTestMain;tmuxtest.Newfails a test in a package without it. When the run ends,TMUXis pointed at a dead socket before the private directory is removed, so a goroutine still running fails rather than falling back to the live default socket.