Run WMFData tests serially to fix global-environment race#5965
Open
davmonk wants to merge 1 commit into
Open
Conversation
Multiple WMFDataTests suites mutate the shared WMFDataEnvironment.current singleton (mediaWikiService/basicService/stores) in their setUp/init. Swift Testing runs suites in parallel by default, so concurrently running suites could overwrite each other's mocked services mid-test, producing intermittent failures (e.g. WMFWatchlistDataControllerTests failing with .serviceError(unableToPullData) when another suite swapped the global service). Per-suite @suite(.serialized) does not fix this: it only serializes tests within a single suite, not separate suites relative to one another. The race is across suites (and the target mixes Swift Testing structs with XCTest classes), so the reliable, low-churn fix is to disable parallel execution for the whole WMFDataTests target in its test plan. Verified locally: max concurrent Swift Testing tests drops from 7 to 1, and the suite passes green across repeated runs. The suite is small, so the serial-execution time cost is negligible. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
davmonk
force-pushed
the
serialize-wmfdata-tests
branch
from
July 14, 2026 15:45
4bc63e8 to
59cb05b
Compare
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.
Problem
Several
WMFDataTestssuites mutate the sharedWMFDataEnvironment.currentsingleton (mediaWikiService/basicService/ stores) in theirsetUp/init. Swift Testing runs suites in parallel by default, so concurrently-running suites can overwrite each other's mocked services mid-test. This produces intermittent failures — e.g.WMFWatchlistDataControllerTests.fetchWatchlistWithProjectFilterfailing with.serviceError(unableToPullData)when another suite swapped the global service out from under it.Why the obvious fixes don't work
@Suite(.serialized)per suite (already present on several suites) only serializes tests within one suite — separate suites still run in parallel relative to one another. This is a cross-suite race.setUp/tearDownsnapshot-restore can't help either: concurrent suites stomp the shared global regardless of restore..serializedbase suite would require converting the XCTest classes — large, risky churn.Fix
Disable parallel execution for the whole
WMFDataTeststarget in its test plan ("parallelizable": false). This is the documented, framework-correct way to serialize an entire target (confirmed by Swift Testing maintainers that the test-plan parallelization setting gates Swift Testing, not just XCTest).Verification
🤖 Generated with Claude Code