Documentation
¶
Overview ¶
Package testtmp provides temp-dir helpers for tests. It is a dependency-free leaf package so any package's tests can use it without import cycles.
On macOS, Spotlight (mds/mdworker) indexes files under the default TMPDIR (/var/folders/...). When a test writes git object files and then removes the dir, the indexer can still be holding a file, so RemoveAll fails with ENOTEMPTY and the test flakes. These helpers address that two ways: a .metadata_never_index marker (the documented Spotlight exclusion) and a bounded retry on RemoveAll.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RobustTempDir ¶
RobustTempDir is like t.TempDir but excludes its subtree from Spotlight and retries cleanup, so a macOS indexing race can't fail an otherwise-passing test. Cleanup is best-effort and never fails the test.
func RunWithIsolatedTemp ¶
RunWithIsolatedTemp runs a package's tests with TMPDIR pointed at a dedicated Spotlight-excluded dir, so every t.TempDir in the package is safe from the macOS indexing race without changing individual tests. Use from TestMain:
func TestMain(m *testing.M) { os.Exit(testtmp.RunWithIsolatedTemp(m)) }
Types ¶
This section is empty.