Skip to content

fix(test): remove t.Parallel from tests using os.Chdir#146

Merged
khaong merged 4 commits intomainfrom
fix/agent-test-parallel-chdir
Feb 5, 2026
Merged

fix(test): remove t.Parallel from tests using os.Chdir#146
khaong merged 4 commits intomainfrom
fix/agent-test-parallel-chdir

Conversation

@khaong
Copy link
Contributor

@khaong khaong commented Feb 4, 2026

Summary

  • Fixes flaky CI failure on main branch caused by tests using os.Chdir() while running in parallel
  • os.Chdir() is process-global, so parallel tests racing to change directories cause unpredictable failures

Changes

Removed t.Parallel() from:

  • TestAgentDetection (parent) and its "claude-code detects presence" subtest
  • TestGeminiCLIAgentDetection (parent) and its "gemini detects presence" subtest

This follows the existing pattern in TestAgentHookInstallation and TestGeminiCLIHookInstallation which correctly avoid t.Parallel() when using os.Chdir.

Test plan

  • mise run test:ci passes locally
  • Verified affected tests pass in isolation
  • Verified affected tests pass when run together

Related

🤖 Generated with Claude Code


Note

Low Risk
Test-only change that reduces concurrency to eliminate os.Chdir() race conditions; no production logic is modified.

Overview
Prevents flaky integration test failures by removing t.Parallel() from the TestAgentDetection and TestGeminiCLIAgentDetection parent tests and from their DetectPresence subtests that change the working directory via os.Chdir().

Adds clarifying comments documenting why these tests must remain non-parallel due to os.Chdir() being process-global.

Written by Cursor Bugbot for commit a61cb36. This will update automatically on new commits. Configure here.

Tests that use os.Chdir() cannot run in parallel because os.Chdir
is process-global. When multiple parallel tests each call os.Chdir
to different directories, they race with each other causing flaky
failures.

Remove t.Parallel() from:
- TestAgentDetection (parent) and its "claude-code detects presence"
  subtest
- TestGeminiCLIAgentDetection (parent) and its "gemini detects presence"
  subtest

This follows the existing pattern in TestAgentHookInstallation and
TestGeminiCLIHookInstallation which correctly avoid t.Parallel()
when using os.Chdir.

Fixes flaky CI failure on main branch.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Entire-Checkpoint: 7ec034df6095
@khaong khaong requested a review from a team as a code owner February 4, 2026 11:21
Copilot AI review requested due to automatic review settings February 4, 2026 11:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes flaky CI failures caused by tests using os.Chdir() while running in parallel. Since os.Chdir() changes the working directory for the entire process, parallel tests that use it can interfere with each other.

Changes:

  • Removed t.Parallel() from TestAgentDetection parent test and its "claude-code detects presence" subtest
  • Removed t.Parallel() from TestGeminiCLIAgentDetection parent test and its "gemini detects presence" subtest
  • Added explanatory comments documenting why these tests cannot run in parallel

@khaong khaong enabled auto-merge February 4, 2026 12:33
@khaong khaong merged commit 1f018fd into main Feb 5, 2026
4 checks passed
@khaong khaong deleted the fix/agent-test-parallel-chdir branch February 5, 2026 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants