Skip to content

Keep the reopen tests from starting real engine work - #216

Merged
bcourbage merged 2 commits into
mainfrom
fix/reopen-tests-engine-isolation
Nov 9, 2026
Merged

bcourbage merged 2 commits into
mainfrom
fix/reopen-tests-engine-isolation

Conversation

@bcourbage

Copy link
Copy Markdown
Owner

Fixes the intermittent CI failure in SessionArgsBridgeTests.test_a_pathScopesScan_andNewSessionInheritsNone, which also turned main red on b179e5e. The cause is a test I added in #212.

Cause

ReopenGateTests drives the real recovery reopen, so test_reopen_proceedsWhenNothingIsHeld runs engine.requestOpen, whose effect calls unison_bridge_init1 on the process-wide OCaml engine (AppDelegate.swift:658). The operation is still in flight when the test ends. SessionArgsBridgeTests runs soon after (the classes sort next to each other), installs its own init handlers, and the stray completion lands in them. The CI log shows the result: the engine reports the archives locked, with the lock owner on the runner's own host (this process), fatal dismissed from the host app's handler, and a 20-second timeout. An earlier run in this series showed "multiple calls made to XCTestExpectation.fulfill", the same signature.

Evidence (local, repeated runs of the two classes)

configuration failures
ReopenGateTests + SessionArgsBridgeTests, before 4 of 8
SessionArgsApplyTests + SessionArgsBridgeTests (control, no engine) 0 of 8
test_reopen_proceedsWhenNothingIsHeld alone + SessionArgsBridgeTests 2 of 8
the remote-close test alone + SessionArgsBridgeTests 0 of 8
ReopenGateTests + SessionArgsBridgeTests, after this change 0 of 14

Change

A test-only AppDelegate.testSuppressEngineEffects (default false, like the existing test switches) skips the effects that drive the engine (connect, scan, sync, diff, close, abort). The coordinator still changes state, so the tests keep asserting the phase reached; ReopenGateTests sets it in setUp and clears it in tearDown. No product behavior changes. The five tests still pass.

Not covered

I did not audit other tests that drive AppDelegate's effect runner for the same leak; the repeated runs above cover only this pair. Full suite passes locally.

🤖 Generated with Claude Code

ReopenGateTests drive the real recovery reopen, whose effects start
unison_bridge_init1 on the process-wide OCaml engine. The operation was left
in flight when the test ended, and it completed into the next engine test's
handlers: SessionArgsBridgeTests then saw its archives locked and timed out.

Add a test-only switch that skips the effects driving the engine while the
coordinator still changes state, and use it in ReopenGateTests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The switch was a static flag set from an async setUp override, which CI's
compiler rejects as sending a non-Sendable XCTestCase. Make it an instance
property compiled only in Debug, set on the delegate each test creates, so
it affects nothing else and needs no setUp or tearDown.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@bcourbage

Copy link
Copy Markdown
Owner Author

CI's first run on this branch failed to compile, not on a test: the async setUp override in a @MainActor test class was rejected as sending a non-Sendable XCTestCase (my local compiler accepts it). Following the review suggestion, the switch is now an instance property compiled only in Debug, set on the delegate each test creates, so no static state and no setUp/tearDown are needed. Re-verified: ReopenGateTests + SessionArgsBridgeTests 0 failures in 14 runs (4 of 8 before the fix); full suite passes locally.

🤖 Generated with Claude Code

@bcourbage
bcourbage merged commit f9678fc into main Nov 9, 2026
2 checks passed
@bcourbage
bcourbage deleted the fix/reopen-tests-engine-isolation branch November 9, 2026 00:34
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