testsupport

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package testsupport holds helpers shared across the module's test suites. It carries no production call sites — only *_test.go files import it — so it stays out of the production binary's build graph.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HardenGitTestEnv

func HardenGitTestEnv()

HardenGitTestEnv prepares the process environment so test fixtures that shell out to git are insulated from the invoking context and from concurrency hazards. Call it once from a package's TestMain — alongside the GIT identity seeding — before m.Run(). It:

  • Unsets the git locator vars (GIT_DIR/GIT_INDEX_FILE/...) a parent git hook exports, which would otherwise steer fixture git commands into the parent repo's gitdir/index (G-0250).
  • Forces gc.auto=0 / gc.autoDetach=false for every child git via GIT_CONFIG_COUNT, so background auto-gc cannot race fixture commits or TempDir cleanup under load (G-0251).

It is safe to call when the locator vars are already unset (os.Unsetenv on an absent key is a no-op) and safe to call from any package whether or not it shells out to git. os.Setenv/Unsetenv (not t.Setenv) because TestMain has no *testing.T and the changes must apply process-wide for the test binary's lifetime — the same reason the identity vars use os.Setenv (t.Setenv panics under t.Parallel). The enforcement chokepoint (policies.PolicyGitTestEnvHardened) requires this call in every exec-bearing internal/* package's TestMain.

Types

This section is empty.

Jump to

Keyboard shortcuts

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