reexectest

package
v0.2026339.1655 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: MIT Imports: 7 Imported by: ? 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 reexectest lets a test observe every execution of its own test binary without recursing. A `go test` binary started with charly arguments ignores them and re-runs its whole suite, so a test that reaches an exec of the running binary (proc.RunCharlySubcommand, a build from the running charly) would recurse; with Record at the top of TestMain such a child appends its arguments to a log and exits instead.

Index

Constants

View Source
const ExitCode = 3

ExitCode is the status a recorded re-execution exits with.

Variables

This section is empty.

Functions

func Log

func Log(t *testing.T) func() string

Log points this test's re-executions at a fresh log and returns a reader of the arguments recorded so far, one execution per line ("" when the binary was never executed).

func Main added in v0.2026339.1557

func Main(m *testing.M) int

Main is the suite-wide TestMain body for a package whose tests may re-execute the test binary. It records every child re-execution at ONE per-run log before m.Run — so a re-execution reached from any test is logged and exits with ExitCode instead of re-running the suite — and fails the run when that log is non-empty: a test that re-executes the binary must opt in with Log(t), and a path that does so without it fails loudly rather than recursing through the whole suite.

func Record

func Record()

Record is called first in TestMain. In a re-executed test binary — started with arguments that are not -test. flags while the log is set — it appends the arguments to the log and exits with ExitCode; otherwise it returns and TestMain runs the suite.

Types

This section is empty.

Jump to

Keyboard shortcuts

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