Skip to content

fix: isolate integration tests from host repo git config#41

Merged
guodong-sq merged 1 commit intomainfrom
fix/integration-test-env-isolation
Mar 21, 2026
Merged

fix: isolate integration tests from host repo git config#41
guodong-sq merged 1 commit intomainfrom
fix/integration-test-env-isolation

Conversation

@guodong-sq
Copy link
Copy Markdown
Collaborator

@guodong-sq guodong-sq commented Mar 21, 2026

Summary

  • Add _WT_SKIP_GIT_CONFIG env var guard to wt_read_git_config() in lib/wt-common
  • Set it in setup_test_env() in test/test_helper/common.bash
  • Unit tests that directly exercise wt_read_git_config unset the guard in their setup()

Problem

When running integration tests locally from a repo with wt.enabled=true in .git/config, wt_read_git_config() finds the real repo's config (highest priority), overwrites the test's isolated WT_* env vars, and commands operate against the wrong repo — causing 57 integration test failures.

Fix

A one-line guard at the top of wt_read_git_config():

[[ -n "${_WT_SKIP_GIT_CONFIG:-}" ]] && return 1

This follows the existing _wt_is_interactive override pattern in lib/wt-adopt.

Test plan

  • All 245 tests pass: cd test && bats unit/ integration/ (was 57 failures before)
  • CI tests continue to pass (CI has no wt.enabled so was unaffected)

🤖 Generated with Claude Code

When running integration tests from inside a repo with wt.enabled=true
in .git/config, wt_read_git_config() picks up the real repo's config
and overwrites the test's isolated WT_* variables, causing all
integration tests to fail with "fatal: invalid reference" errors.

Add _WT_SKIP_GIT_CONFIG env var guard to wt_read_git_config() that
tests set via setup_test_env(). This follows the existing pattern of
_wt_is_interactive override in lib/wt-adopt for test overrides.

Unit tests that directly exercise wt_read_git_config unset the guard
in their setup() so they can test the function against their own mock
repos.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@guodong-sq guodong-sq merged commit 8eb9f15 into main Mar 21, 2026
5 checks passed
@guodong-sq guodong-sq deleted the fix/integration-test-env-isolation branch March 24, 2026 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant