Skip to content

Fail fast when -waitForWorktrees times out, and give it more headroom - #734

Merged
hannesa2 merged 2 commits into
masterfrom
fix/worktree-add-test-ci-flake
Sep 27, 2026
Merged

hannesa2 merged 2 commits into
masterfrom
fix/worktree-add-test-ci-flake

Conversation

@hannesa2

@hannesa2 hannesa2 commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

testANewWorktreeCanStartANewBranch failed on CI
(https://github.com/gitx/gitx/actions/runs/... arm64, macOS 26.6.2) with (null) not equal to refs/heads/fresh: -waitForWorktrees' 10-second poll for the async git worktree list reload timed out silently on the shared runner, so the test read the worktree list before the new worktree ever appeared and failed on the unrelated -branchRefName comparison instead.

-waitForWorktrees now asserts its own condition once the wait ends, so a stall shows up there with a clear message, and the window is 20s rather than 10s to give a loaded CI runner more room before that assertion fires.

@hannesa2 hannesa2 added the test Test related label Sep 27, 2026
@hannesa2
hannesa2 requested review from goneng and a lite review from Copilot September 27, 2026 12:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The only noted issue is a minor diagnostic nit; the requested reliability changes are otherwise complete.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

Improves worktree test reliability by extending the async wait timeout and reporting timeout failures clearly.

Changes:

  • Increases timeout from 10 to 20 seconds.
  • Adds an assertion when the expected worktree state is not reached.
File Description
GitXTests/​PBGitWorktreeManagementTests.m Updates worktree polling timeout and failure reporting.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

while (!condition([self second]) && [limit timeIntervalSinceNow] > 0)
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.01]];

XCTAssertTrue(condition([self second]), @"Worktrees did not reach the expected state before the wait timed out");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if my change make sense at all. I only see, that it's now error free

@goneng

goneng commented Sep 27, 2026

Copy link
Copy Markdown
Collaborator

@hannesa2 the (null) may come from a race rather than a timeout: a git worktree list still running from setUp can read the list mid-worktree add, when git shows the new worktree as HEAD 0000..., detached, locked initializing (reproduced locally with git 2.55). The wait sees fresh-here exist and returns, so the new assert passes and the branch check still fails.

Suggestion: wait for the branch too, in both add tests (L464-L467, L475-L478), e.g. return [[self worktreeNamed:@"fresh-here"].branchRefName isEqualToString:@"refs/heads/fresh"];

testANewWorktreeCanStartANewBranch failed on CI
(https://github.com/gitx/gitx/actions/runs/... arm64, macOS 26.6.2)
with '(null)' not equal to 'refs/heads/fresh': -waitForWorktrees'
10-second poll for the async `git worktree list` reload timed out
silently on the shared runner, so the test read the worktree list
before the new worktree ever appeared and failed on the unrelated
-branchRefName comparison instead.

-waitForWorktrees now asserts its own condition once the wait ends, so
a stall shows up there with a clear message, and the window is 20s
rather than 10s to give a loaded CI runner more room before that
assertion fires.
the (null) may come from a race rather than a timeout: a git worktree list still running from setUp can read the list mid-worktree add, when git shows the new worktree as HEAD 0000..., detached, locked initializing (reproduced locally with git 2.55). The wait sees fresh-here exist and returns, so the new assert passes and the branch check still fails.
@hannesa2
hannesa2 force-pushed the fix/worktree-add-test-ci-flake branch from 73de521 to 2f862af Compare September 27, 2026 16:32
@hannesa2

Copy link
Copy Markdown
Contributor Author

I applied your suggestion

@hannesa2
hannesa2 merged commit f3f5121 into master Sep 27, 2026
3 checks passed
@hannesa2
hannesa2 deleted the fix/worktree-add-test-ci-flake branch September 27, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants