Skip to content

fix(tests): eliminate env-var race in Windows checkpoint timeout tests#1067

Open
svarlamov wants to merge 2 commits intomainfrom
fix/windows-test-race
Open

fix(tests): eliminate env-var race in Windows checkpoint timeout tests#1067
svarlamov wants to merge 2 commits intomainfrom
fix/windows-test-race

Conversation

@svarlamov
Copy link
Copy Markdown
Member

@svarlamov svarlamov commented Apr 13, 2026

Summary

  • Root cause: queued_checkpoint_requests_use_short_timeout_in_product_env was flaky on Windows CI because TmpRepo::new() permanently sets GIT_AI_TEST_DB_PATH in the process environment. With --test-threads=4, concurrent non-#[serial] tests calling TmpRepo::new() would race against the EnvVarGuard unsets in the serial test, causing checkpoint_control_timeout_uses_ci_or_test_budget() to see the env var as set and return true (→ 300s) instead of false (→ 2s).
  • Fix: The three checkpoint timeout logic tests now call checkpoint_control_response_timeout directly with an explicit boolean, making them pure, deterministic, and race-free. Moved env-var integration coverage into three new dedicated #[serial] tests for checkpoint_control_timeout_uses_ci_or_test_budget itself.

Test plan

  • daemon::tests::queued_checkpoint_requests_use_short_timeout_in_product_env passes on Windows
  • All daemon::tests::checkpoint* tests pass on all platforms
  • No other tests broken

🤖 Generated with Claude Code


Open with Devin

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>
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

…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>
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