fix(tests): eliminate env-var race in Windows checkpoint timeout tests#1067
Open
fix(tests): eliminate env-var race in Windows checkpoint timeout tests#1067
Conversation
The three checkpoint timeout tests were using `control_request_response_timeout` which reads process-level env vars (CI, GIT_AI_TEST_DB_PATH, GITAI_TEST_DB_PATH). With `--test-threads=4`, non-serial tests calling `TmpRepo::new()` concurrently would permanently set `GIT_AI_TEST_DB_PATH` in the process environment, racing against the `EnvVarGuard` unsets in these serial tests and causing them to see `use_ci_or_test_budget=true` when they expected `false`. Fix by testing `checkpoint_control_response_timeout` directly with explicit boolean parameters — the pure logic no longer depends on env var state, making the tests deterministic and removing the need for `#[serial]`. Add three focused `#[serial]` tests for `checkpoint_control_timeout_uses_ci_or_test_budget` itself, since that function is the one that reads env vars. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…orking_dir In daemon mode, configure_git_ai_env sets GIT_AI_DAEMON_CHECKPOINT_DELEGATE=true, which causes checkpoints to be queued to the daemon asynchronously. git_ai_from_working_dir is used for cross-repo and cross-CWD scenarios where the checkpoint may target a *different* repo's family than self (e.g. nested subrepos). Waiting on self's family completion log after an async delegate would either time out (wrong family) or race. Fix: remove the delegate flag immediately after configure_git_ai_env so the checkpoint runs synchronously in the subprocess, guaranteeing the working log is written before the function returns. This restores correct behavior for all cross-repo attribution tests that check the working log immediately after the checkpoint call. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
queued_checkpoint_requests_use_short_timeout_in_product_envwas flaky on Windows CI becauseTmpRepo::new()permanently setsGIT_AI_TEST_DB_PATHin the process environment. With--test-threads=4, concurrent non-#[serial]tests callingTmpRepo::new()would race against theEnvVarGuardunsets in the serial test, causingcheckpoint_control_timeout_uses_ci_or_test_budget()to see the env var as set and returntrue(→ 300s) instead offalse(→ 2s).checkpoint_control_response_timeoutdirectly with an explicit boolean, making them pure, deterministic, and race-free. Moved env-var integration coverage into three new dedicated#[serial]tests forcheckpoint_control_timeout_uses_ci_or_test_budgetitself.Test plan
daemon::tests::queued_checkpoint_requests_use_short_timeout_in_product_envpasses on Windowsdaemon::tests::checkpoint*tests pass on all platforms🤖 Generated with Claude Code