test(binarymgr): isolate runner_test config writes from the user's config
Description
- test(binarymgr): isolate runner_test config writes from the user's config
This change fixes a test configuration issue to prevent tests from accidentally overwriting the user's real configuration files. Previously, tests were using an in-memory configuration that could potentially interfere with actual user settings. Now, each test creates its own temporary directory and points the configuration system to use that isolated location instead of the user's home directory. As a side effect, the tests can no longer run in parallel because they modify environment variables that are shared across the entire program, so the parallel execution flags were removed to prevent conflicts.
Test plan
What changed
internal/binarymgr/runner_test.go::runnerFor now sets GLAB_CONFIG_DIR to a per-test t.TempDir() before constructing the blank config, so Cfg.Write() lands in the temp
dir instead of clobbering ~/.config/glab-cli/config.yml. Affected tests had t.Parallel() removed because t.Setenv is incompatible with parallel tests.
Pre-flight
Verify your real config is in a known state (clean of any prior leakage):
sed -i.bak '/^test_cli_/d' ~/.config/glab-cli/config.yml
grep -E "^test_cli" ~/.config/glab-cli/config.yml || echo "clean"
# Snapshot the real config so we can prove it isn't touched.
shasum ~/.config/glab-cli/config.yml > /tmp/glab-config.shasum
cp ~/.config/glab-cli/config.yml /tmp/glab-config.beforeConfirm the bug exists on main (optional but recommended)
git stash # set the fix aside
go test -count=1 -run TestRunner_save ./internal/binarymgr/...
grep -E "^test_cli" ~/.config/glab-cli/config.yml # <-- leaks visible
diff -q /tmp/glab-config.before ~/.config/glab-cli/config.yml
# /tmp/glab-config.before differs
# Restore safe state before testing the fix
cp /tmp/glab-config.before ~/.config/glab-cli/config.yml
git stash popVerify the fix
# 1. Run the patched tests.
go test -count=1 -v -run TestRunner_save ./internal/binarymgr/...
# 2. Run the broader packages that exercise the same Runner helpers.
go test -count=1 ./internal/binarymgr/... \
./internal/commands/orbit/local/... \
./internal/commands/duo/cli/...
# 3. Real config must be byte-identical to the snapshot.
shasum -c /tmp/glab-config.shasum
diff -q /tmp/glab-config.before ~/.config/glab-cli/config.yml
# 4. No test keys leaked.
grep -E "^test_cli" ~/.config/glab-cli/config.yml || echo "clean ✓"Expected output
- All test packages report
ok. shasum -creportsOK.diff -qreports no output.grep -E "^test_cli"printsclean ✓.