fix(test): remove t.Parallel from tests using os.Chdir#146
Merged
Conversation
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
Contributor
There was a problem hiding this comment.
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()fromTestAgentDetectionparent test and its"claude-code detects presence"subtest - Removed
t.Parallel()fromTestGeminiCLIAgentDetectionparent test and its"gemini detects presence"subtest - Added explanatory comments documenting why these tests cannot run in parallel
gtrrz-victor
approved these changes
Feb 5, 2026
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
os.Chdir()while running in parallelos.Chdir()is process-global, so parallel tests racing to change directories cause unpredictable failuresChanges
Removed
t.Parallel()from:TestAgentDetection(parent) and its"claude-code detects presence"subtestTestGeminiCLIAgentDetection(parent) and its"gemini detects presence"subtestThis follows the existing pattern in
TestAgentHookInstallationandTestGeminiCLIHookInstallationwhich correctly avoidt.Parallel()when usingos.Chdir.Test plan
mise run test:cipasses locallyRelated
t.Parallel()usage - this fix adds a caveat that tests usingos.Chdirshould NOT be parallel🤖 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 theTestAgentDetectionandTestGeminiCLIAgentDetectionparent tests and from theirDetectPresencesubtests that change the working directory viaos.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.