Skip to content

Move three Foundation extensions into the cross-platform Swift package tests#25825

Merged
jkmassel merged 3 commits into
trunkfrom
jkmassel/foundation-ext-swift-test
Jul 22, 2026
Merged

Move three Foundation extensions into the cross-platform Swift package tests#25825
jkmassel merged 3 commits into
trunkfrom
jkmassel/foundation-ext-swift-test

Conversation

@jkmassel

Copy link
Copy Markdown
Contributor

Continues #25815. Moves three Foundation-extension test suites — and the source they exercise — out of the Xcode-only KeystoneTests bundle into WordPressShared, so they run under swift test at the repo root: the macOS cross-platform gate from #25344, which runs on a bare checkout with no Xcode project, no simulator, and no app build, in about 20 seconds.

Each subject was already an import Foundation-only leaf trapped inside a UIKit-bound module — AztecExtensions, FormattableContentKit, and WordPressKit — none of which build on macOS. Relocating the leaf into WordPressShared (which all three already depend on) is cheaper than standing up a macOS test target for those heavier modules, and gets the test across the gate.

Summary

  • URL.normalizedURLForWordPressLink() — out of AztecExtensions
  • Scanner.scanQuotedText() — out of FormattableContentKit (made public for the module boundary)
  • NSAttributedString.trimNewlines() — out of WordPressKit, plus a dedup (below)
  • Root swift test gains 8 XCTest cases (URL 1, Scanner 5, NSAttributedString 2); the iOS suite keeps every one of these via the existing WordPressSharedTests target in WordPressUnitTests.xctestplan.

The trimNewlines duplicate

FormattableContentKit carried a byte-identical internal copy of trimNewlines() on NSAttributedString, alongside the @objc public one in WordPressKit. Moving the WordPressKit copy into WordPressShared lets this PR delete that duplicate and route both callers — FormattableContentFormatter (FCK) and RichNotificationContentFormatter (the notification service extension) — to the single definition.

Caller changes

Minimal, because the destination module was already imported almost everywhere:

  • AztecPostViewController and FormattableContentFormatter already import WordPressShared → unchanged.
  • NSMutableAttributedString.applyAttributes(toQuotes:) (FCK) and RichNotificationContentFormatter (NSE) each pick up one import WordPressShared.
  • WordPress/Classes and Tests/KeystoneTests are file-system-synchronized groups, so none of this needs .pbxproj edits.

Not in this PR

The fourth remaining Foundation-extension test, NSMutableAttributedStringTests (applyStylesToMatchesWithPattern), needs more than a move — its subject shares an app file with a UIImage-based sibling, and the test itself builds styles out of UIFont/UIColor, which don't exist on macOS. It's a separate follow-up (source split + test rewrite).

Test plan

  • swift test from the repo root: the 3 moved suites run under WordPressSharedTests — URL 1, Scanner 5, NSAttributedString 2 — 0 failures.
  • xcodebuild build-for-testing -scheme WordPress -testPlan WordPressUnitTests -destination 'generic/platform=iOS Simulator': ** TEST BUILD SUCCEEDED ** — the app, notification service extension, AztecExtensions, FormattableContentKit, WordPressKit, KeystoneTests, and every Modules/* test target still compile.
  • swiftlint: 0 violations across the 8 changed Swift files.

Related

jkmassel added 3 commits July 22, 2026 14:30
The extension was a pure-Foundation leaf living in AztecExtensions, which
is UIKit/Aztec-bound and can't build on macOS. Relocating it to
WordPressShared lets URL+LinkNormalizationTests run under the root
`swift test` cross-platform gate instead of the Xcode-only KeystoneTests
bundle. AztecPostViewController already imports WordPressShared, so no
caller changes are needed.
The extension was a pure-Foundation leaf in FormattableContentKit, which
has UIKit-bound files (notification styling, image maps) and so can't
build on macOS. Relocating it to WordPressShared lets ScannerTests run
under the root `swift test` cross-platform gate. The method becomes
public for the module boundary; its one internal caller
(NSMutableAttributedString.applyAttributes(toQuotes:)) picks up an
import WordPressShared.
The @objc extension lived in WordPressKit, which has UIKit-bound files
and doesn't build on macOS. Relocating it to WordPressShared lets
NSAttributedStringTests run under the root `swift test` cross-platform
gate.

FormattableContentKit carried a byte-identical internal copy of
trimNewlines() on NSAttributedString; this deletes that duplicate and
routes both it and the notification service extension's
RichNotificationContentFormatter to the single WordPressShared
definition.
@wpmobilebot

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 Number33357
VersionPR #25825
Bundle IDorg.wordpress.alpha
Commit614aa18
Installation URL7q02kkned9be0
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
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 Number33357
VersionPR #25825
Bundle IDcom.jetpack.alpha
Commit614aa18
Installation URL42tkc5dbtngn0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@jkmassel jkmassel added the Testing Unit and UI Tests and Tooling label Jul 22, 2026
@jkmassel jkmassel added this to the 27.2 milestone Jul 22, 2026
@jkmassel
jkmassel added this pull request to the merge queue Jul 22, 2026
Merged via the queue into trunk with commit ff20879 Jul 22, 2026
30 of 31 checks passed
@jkmassel
jkmassel deleted the jkmassel/foundation-ext-swift-test branch July 22, 2026 23:53
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