Skip to content

Move eligible KeystoneTests into the cross-platform Swift package tests#25815

Merged
jkmassel merged 3 commits into
trunkfrom
jkmassel/migrate-tests-to-modules
Jul 23, 2026
Merged

Move eligible KeystoneTests into the cross-platform Swift package tests#25815
jkmassel merged 3 commits into
trunkfrom
jkmassel/migrate-tests-to-modules

Conversation

@jkmassel

@jkmassel jkmassel commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Moves 11 test suites — and the sources they exercise — out of the Xcode-only KeystoneTests bundle into WordPressShared, so they run under swift test at the repo root. That's the macOS cross-platform gate added in #25344: it runs on a bare checkout with no Xcode project, no simulator, and no app build, in about 20 seconds. These suites previously only ran inside the full iOS unit-test build.

Summary

  • Relocate 12 test files from Tests/KeystoneTests to Modules/Tests/WordPressSharedTests.
  • Extract 10 source files from the app target into Modules/Sources/WordPressShared so those tests have a macOS-buildable subject to import.
  • Delete 2 stale Keystone duplicates (DictionaryHelpersTests, URLIncrementalFilenameTests) whose WordPressShared copies already ran.
  • Adds 41 XCTest cases to the root swift test run; the iOS suite keeps every one of these tests via the existing WordPressSharedTests target in WordPressUnitTests.xctestplan.

What moved

All into WordPressShared, with the test alongside in WordPressSharedTests: Queue, Array extensions, Math extensions, NotificationCenter.observeOnce, LoggingURLRedactor, IncrementalDelay (split out of Delay.swift, leaving the DispatchDelayedAction/DelayStateWrapper GCD helpers in the app), QRLoginURLParser/QRLoginToken, ReaderCSS, SiteCreationHeaderData, DashboardDynamicCardAnalyticsEvent.

The two commits map to these groups: the utility batch, and the Array/Math/NotificationCenter/IncrementalDelay batch.

Why a test move drags a source move

swift test at the root builds the WordPressCrossPlatformModules package, which depends only on macOS-clean products. A test can only run there if its subject lives in one of those modules — so each extracted type moves into WordPressShared, gets the members the app touches marked public, and every remaining caller picks up an import WordPressShared. Because WordPress/Classes and Tests/KeystoneTests are file-system-synchronized groups, none of this needs .pbxproj edits.

Sources with user-facing NSLocalizedString were left in place on purpose. Moving translated strings into a module changes their bundle at lookup time and drops them from the app's GlotPress extraction, so candidates like SiteIntentData, ErrorStateViewConfiguration, PluginStore, and MediaSizeSliderCell are excluded here.

Not the Gutenberg processors

An earlier revision of this PR also extracted the Gutenberg content processors into WordPressShared. #25811 landed the same extraction independently — into a dedicated GutenbergProcessors module, with the SwiftSoup 2.13.6 serialization fix — so that work is dropped here to avoid duplicating it. Those suites already run under swift test via GutenbergProcessorsTests. The one exception MediaUploadHashTests (a String.hash guard with no processor dependency, which #25811 left in Keystone) is relocated to WordPressSharedTests here.

Not in this PR

Remaining KeystoneTests candidates each need infrastructure this PR doesn't add, and are follow-ups: a macOS WordPressKitTests root target (unblocks NSAttributedString, SiteSegment, TimeZoneFormatter, Pinghub, StatsPeriodAsyncOperation, the Dashboard view models); resource-bundle support on WordPressSharedTests for fixture-based tests (StockPhotos, SiteSegment, PluginDirectoryEntry); WordPressCore extractions entangled with the feature-flag store; and a new module for the WhatsNew announcement store.

Test plan

  • swift test from the repo root: the 12 relocated suites run under the WordPressSharedTests.xctest bundle — 41 tests, 0 failures (part of the full cross-platform run on the rebased branch, alongside trunk's other suites).
  • xcodebuild build-for-testing -scheme WordPress against current trunk: ** TEST BUILD SUCCEEDED ** — the app, KeystoneTests, and every Modules/* test target still compile.
  • swiftlint --strict: 0 violations across the changed Swift files.
  • CI build #33337 confirmed these 12 suites run under WordPressSharedTests in the iOS Unit Tests job and none remain in the WordPressTest (Keystone) bundle (that run predates dropping the Gutenberg commit; the merge queue re-validates the current HEAD).

@wpmobilebot

wpmobilebot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number33414
VersionPR #25815
Bundle IDorg.wordpress.alpha
Commiteb9545f
Installation URL2cc9hgh2pusn0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number33414
VersionPR #25815
Bundle IDcom.jetpack.alpha
Commiteb9545f
Installation URL1rkc6290nsb90
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

Copy link
Copy Markdown
Contributor

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

@jkmassel
jkmassel added this pull request to the merge queue Jul 22, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 22, 2026
@jkmassel
jkmassel added this pull request to the merge queue Jul 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 23, 2026
@jkmassel
jkmassel force-pushed the jkmassel/migrate-tests-to-modules branch 2 times, most recently from 4c13b73 to 60ff71e Compare July 23, 2026 21:05
jkmassel added 3 commits July 23, 2026 15:16
Relocate the Queue, LoggingURLRedactor, DashboardDynamicCardAnalyticsEvent,
SiteCreationHeaderData, QRLoginURLParser, and ReaderCSS tests from KeystoneTests
into WordPressSharedTests, moving each subject into WordPressShared so it builds
on macOS and runs under `swift test` at the repo root. Also move URLHelpersTests
and delete two stale KeystoneTests copies (DictionaryHelpersTests,
URLIncrementalFilenameTests) whose WordPressShared copies already ran.
…PressShared

Move the Array and Math extensions and NotificationCenter.observeOnce into
WordPressShared, and split IncrementalDelay out of Delay.swift (leaving the GCD
DispatchDelayedAction/DelayStateWrapper helpers in the app). Relocate their
tests into WordPressSharedTests and add the WordPressShared import to the
remaining callers.
Relocate the String.hash guard test from KeystoneTests to WordPressSharedTests
so it runs under `swift test` at the repo root. #25811 moved the other Gutenberg
tests into GutenbergProcessorsTests but left this one behind — it asserts a
Swift String hash value and has no processor dependency. Drops the vestigial
`@testable import WordPress`.
@jkmassel
jkmassel force-pushed the jkmassel/migrate-tests-to-modules branch from 60ff71e to eb9545f Compare July 23, 2026 21:16
@jkmassel
jkmassel added this pull request to the merge queue Jul 23, 2026
Merged via the queue into trunk with commit 7c5fe8e Jul 23, 2026
28 checks passed
@jkmassel
jkmassel deleted the jkmassel/migrate-tests-to-modules branch July 23, 2026 21:54
jkmassel added a commit that referenced this pull request Jul 23, 2026
#25815 (KeystoneTests move) and #25825 (Foundation extensions) relocated 15 more XCTest suites into WordPressSharedTests after this branch was first written; convert them too so the swift test set stays entirely Swift Testing. NotificationCenterObserveOnceTests is pinned to @suite(.serialized) because its two tests share NotificationCenter.default and would race under Swift Testing's parallelism; QueueTests stays a final class because Queue is a value type it mutates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Testing Unit and UI Tests and Tooling [Type] Tech Debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants