testenv

package
v0.73.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testenv makes a test binary hermetic. HOME, the ledger, the asks and run dirs go under one temp root, and the developer's git config and shell environment are ignored. The Go caches are the one exception, kept on the developer's own by PinGoDirs. It imports nothing from this module, so any package's tests may use it. cmd/f10's tests check its paths against the real ones.

Index

Constants

This section is empty.

Variables

View Source
var Cleared = []string{
	"XDG_CONFIG_HOME", "F10_STATE_DIR", "F10_USER_DIR", "CLAUDE_CONFIG_DIR", "GH_CONFIG_DIR", "GLAB_CONFIG_DIR",
	"F10_BATCH_FILE", "F10_BATCH_RESUMES", "F10_DRIVE_FILE", "F10_DRIVE_RESUMES",
	"F10_AGENT_MODEL", "F10_AGENT_VIA", "F10_AGENT_SESSION",
	"F10_SESSION_ID", "CLAUDE_CODE_SESSION_ID", "CLAUDECODE",
	"HERDR_ENV", "HERDR_WORKSPACE_ID",
	"F10_ROOTS", "F10_STATE_TTL", "F10_STATE_DEBUG",
	"F10_PLUGIN_ROOT", "CLAUDE_PLUGIN_ROOT",
	"F10_STANDUP_RECORD", "F10_BOARD_RECORD", "F10_STATUS_GLYPHS",
	"XDG_RUNTIME_DIR",
}

Cleared is the environment the developer's shell may set, which would otherwise leak into the tests. The dir overrides among it are cleared, not pinned, so they follow HOME and a test that moves HOME moves them too.

View Source
var Root string

Root holds every user-level dir for the run, so a test that sets nothing still never reads or writes the developer's own HOME, bar the Go caches.

Functions

func Home

func Home() string

Home is the HOME the tests run under.

func Main

func Main(m *testing.M)

Main sets the environment up, runs the tests and exits with their code.

func PinGoDirs added in v0.73.0

func PinGoDirs(home string)

PinGoDirs sets the Go caches and config to the values go resolves under home, so every child process keeps them whatever HOME a test moves to. Unlike the f10 dirs they are pinned, not cleared: left to follow a moved HOME, a build starts cold and writes a read-only module cache t.TempDir cannot remove. Without go it does nothing.

func Setup

func Setup() func()

Setup makes Root and points the user-level dirs into it, returning what removes them. A TestMain that also swaps seams calls it before m.Run.

func UserDir

func UserDir() string

UserDir is the user's f10 dir under Home, where the notify switch lives.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL