Help us shape the future of Go! Take the 2026 Go Developer Survey

testutil

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FossilArtifactByPath

func FossilArtifactByPath(repoPath, uuid string) ([]byte, error)

func FossilBinary

func FossilBinary() string

FossilBinary resolves the canonical fossil binary: the FOSSIL_BIN override first, then PATH. An override that does not resolve to an executable is treated as no binary at all, so the caller reports "fossil not found" rather than letting a stale path surface later as a raw fork/exec error.

func FossilRebuild

func FossilRebuild(repoPath string) error

func FossilTimeline

func FossilTimeline(repoPath string) ([]byte, error)

func IsolateFossilHome added in v0.12.0

func IsolateFossilHome(t *testing.T) string

IsolateFossilHome points HOME, FOSSIL_HOME and XDG_CONFIG_HOME at a fresh per-test directory for the rest of the test, and returns it. Fossil keeps a per-user database (~/.fossil or ~/.config/fossil.db) and records every repository and checkout it touches there, never removing the rows; without this, each test run leaks rows into the developer's real config and contends for its lock (#284). Child processes inherit the environment, so every exec.Command in the test is covered without per-call plumbing. RequireFossilBin calls it, so a test that resolves the binary through that gets isolation by default; tests that resolve fossil another way must call it themselves (TestFossilInvocationsIsolateHome enforces this). It cannot be used from a parallel test: t.Setenv panics there, which is the intended loud failure, since a shared process environment cannot be isolated per test.

func RequireFossilBin

func RequireFossilBin(t *testing.T) string

RequireFossilBin resolves the fossil binary for tests that need canonical Fossil to run. It resolves the same way FossilBinary does (the FOSSIL_BIN override, then PATH). When no binary is found it skips the test, unless REQUIRE_FOSSIL_BIN=1 is set -- then it fails. That makes CI turn a missing binary into a loud failure (verifying real Fossil reads what we write is the one thing our own tests cannot substitute for) while local runs without fossil installed stay an opt-in skip.

func StartServer added in v0.12.0

func StartServer(t *testing.T, bin string, args ...string) *exec.Cmd

StartServer runs `bin args...` as a long-lived server and stops it when the test ends. The server gets its own process group and cleanup kills the whole group before reaping the parent. `fossil server` forks a child per connection, so killing only the parent leaves a child that can still write journal/WAL files while t.TempDir()'s RemoveAll walks the directory, which fails cleanup with "directory not empty" (#352).

Call it after t.TempDir() so its cleanup runs first (Cleanup is LIFO).

Types

type TestRepo

type TestRepo struct {
	Path string
	Dir  string
}

func NewTestRepo

func NewTestRepo(t *testing.T) *TestRepo

func NewTestRepoFromPath

func NewTestRepoFromPath(t *testing.T, path string) *TestRepo

func (*TestRepo) FossilArtifact

func (r *TestRepo) FossilArtifact(t *testing.T, uuid string) []byte

func (*TestRepo) FossilRebuild

func (r *TestRepo) FossilRebuild(t *testing.T)

func (*TestRepo) FossilSQL

func (r *TestRepo) FossilSQL(t *testing.T, sql string) string

Jump to

Keyboard shortcuts

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