Skip to content

Check the main queue, not the main thread, in main-actor turn tests - #105

Merged
dfed merged 1 commit into
mainfrom
claude/project-thread-ennj0t
Nov 17, 2026
Merged

dfed merged 1 commit into
mainfrom
claude/project-thread-ennj0t

Conversation

@dfed

@dfed dfed commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Requested by Dan · project thread

Problem

The six …endsItsTurnOnMainActor tests from #101 record Thread.isMainThread each time a turn ends. On Linux, threads other than the main thread run the main dispatch queue's work, so code on the main actor can run off of the main thread. All six tests fail in a debug swift test on Linux (reproduced in swift:6.4 on main). CI missed it because both Linux jobs build with -c release, which compiles these #if DEBUG tests out.

Changes

  • The tests now record whether each turn ended on the main dispatch queue, using the DispatchSpecificKey that ManualTaskExecutor already used. The key moves to TestHelpers.swift as a shared isOnMainQueue.
  • The pinned Linux job gets a Test Debug Build step that runs swift test, so tests under #if DEBUG run on Linux. No job names change, so the required checks are unaffected.

Nothing in Sources changes, so no release is needed.

Verification (Linux, swift:6.4, debug)

  • Full suite passes 10 of 10 runs with this change; the release suite still passes.
  • The tests still catch the regressions they guard, each failing 10 of 10 runs:
    • Removing @MainActor from FIFOQueue's two executeOnMainActor functions, so turns end off of the main actor: all six tests fail.
    • Removing @MainActor in from CancellableQueue's main-actor wrappers: both CancellableQueue tests fail.
  • The [false, true] tests confirm the check reports false off of the main queue.
  • swiftformat --lint is clean.

Generated by Claude Code

The six `endsItsTurnOnMainActor` tests recorded `Thread.isMainThread`
each time a turn ended. On Linux, threads other than the main thread
run the main dispatch queue's work, so code on the main actor can run
off of the main thread, and all six tests failed in a debug build. CI
missed it because both Linux jobs build in release, which compiles
these tests out.

Record whether each turn ended on the main dispatch queue instead,
with the main-queue key that `ManualTaskExecutor` already used, now
shared as `isOnMainQueue`. On Linux the tests pass 10 of 10 debug runs,
and still fail 10 of 10 runs when `FIFOQueue` ends a main-actor task's
turn off of the main actor, or when `CancellableQueue` doesn't isolate
its wrapper to the main actor.

Add a debug `swift test` step to the pinned Linux job so that tests
under `#if DEBUG` run on Linux.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HLuVQNGMJwKLhXGryHUn5X
@dfed dfed self-assigned this Nov 17, 2026
@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ccbfc26) to head (0ac3e2c).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #105   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           15        15           
  Lines         3605      3607    +2     
=========================================
+ Hits          3605      3607    +2     
Files with missing lines Coverage Δ
Tests/AsyncQueueTests/CancellableQueueTests.swift 100.00% <100.00%> (ø)
Tests/AsyncQueueTests/FIFOQueueTests.swift 100.00% <100.00%> (ø)
...ts/AsyncQueueTests/Utilities/ManualExecutors.swift 100.00% <100.00%> (ø)
Tests/AsyncQueueTests/Utilities/TestHelpers.swift 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dfed
dfed enabled auto-merge (squash) November 17, 2026 05:16
@dfed
dfed disabled auto-merge November 17, 2026 05:17
@dfed
dfed merged commit 32c1c9d into main Nov 17, 2026
15 checks passed
@dfed
dfed deleted the claude/project-thread-ennj0t branch November 17, 2026 05:43
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.

2 participants