testutil

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package testutil provides shared test helpers for saving per-test artifacts to persistent output directories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RepoRoot

func RepoRoot() string

RepoRoot returns the project root by walking up from the caller's source file to the nearest directory containing go.mod.

func RunTimestamp

func RunTimestamp() string

RunTimestamp returns a stable timestamp for the current test binary run. All tests in the same `go test` invocation share the same value.

func ShortSHA

func ShortSHA() string

ShortSHA returns the abbreviated commit hash of HEAD.

func TestResultsDir

func TestResultsDir(t *testing.T, baseDirFn func() string) string

TestResultsDir returns a persistent results directory for a test:

test/results/<timestamp>-<RootTestName>/<subtest/path>/

All subtests of the same root test share one timestamped parent directory. The directory is created automatically.

baseDirFn optionally overrides the base directory (the directory containing test/results/). When nil, RepoRoot() is used. Pass a custom function when the results path must be remapped (e.g. Docker host path translation).

Types

This section is empty.

Jump to

Keyboard shortcuts

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