Skip to content

Fix cyclic dependency test race#8

Merged
robert-northmind merged 1 commit into
mainfrom
codex/fix-cyclic-handler-test-race
Apr 7, 2026
Merged

Fix cyclic dependency test race#8
robert-northmind merged 1 commit into
mainfrom
codex/fix-cyclic-handler-test-race

Conversation

@robert-northmind

Copy link
Copy Markdown
Owner

What changed

This fixes a race introduced in the recent re-entrant resolve test coverage.

The new issue #5 test in ReentrantResolveTests.swift overrides the shared global cyclicDependencyHandler, but the existing cyclic dependency test in SwiftiePodTests.swift does the same. Because Swift Testing runs tests in parallel, those two tests could interfere with each other and assert against the wrong handler output.

This PR makes the test setup exclusive when replacing cyclicDependencyHandler, and also aligns the re-entrant test worker queues with user-initiated QoS.

Why

The regression was reproducible in the test suite itself:

  • xcodebuild test -scheme SwiftiePod -destination 'platform=macOS'

Before this fix, the two cyclic-dependency tests could fail nondeterministically because they were mutating shared global state at the same time.

Root cause

Both tests relied on swapping a process-global handler:

  • Tests/SwiftiePodTests/SwiftiePodTests.swift
  • Tests/SwiftiePodTests/ReentrantResolveTests.swift

That was safe while run in isolation, but not once both tests were eligible to execute concurrently.

Implementation

  • Added a small test-only lock helper in Tests/SwiftiePodTests/TestUtils.swift
  • Wrapped both handler-mutating tests in that exclusive section
  • Switched the re-entrant test background work to user-initiated queues

Impact

This change is test-only. It does not modify library/runtime behavior in Sources/.

It removes a flaky test interaction and keeps the newer re-entrant cycle coverage in place.

Validation

  • xcodebuild test -scheme SwiftiePod -destination 'platform=macOS'

@robert-northmind
robert-northmind merged commit 7663034 into main Apr 7, 2026
2 checks passed
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