testenv

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package testenv provides shared process-environment isolation for test binaries. Blank-import this from any test package whose tests invoke `git` so the developer's global git config (`~/.gitconfig`) does not leak into the subprocess environment.

What this avoids: when a developer has `commit.gpgsign=true` and a passphrase-protected SSH/GPG signing key configured globally, every `git commit` in a test fixture inherits that config and blocks waiting for a passphrase prompt the test runner cannot satisfy. Result: cascade failures across `internal/codedb/index`, `internal/doctor`, `internal/repotools`, `internal/uninstall`, `internal/secrets`, etc.

The Makefile (`TEST_GIT_ISOLATION` in the `test`/`test-cover`/ `test-all`/`test-slow` recipes) sets the same env vars at the `make`-driver level. This package covers the direct `go test ./pkg/` case — which IDE-driven runs and ad-hoc `go test` use — so the passing/failing posture is identical whether tests are invoked via make or go.

Usage:

package mypkg_test

import (
    _ "github.com/sageox/ox/internal/testenv"
)

init() honors existing env vars; if the Makefile or a CI environment already set them, we leave those values in place.

Jump to

Keyboard shortcuts

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