Skip to content

Move five untested Foundation extensions to WordPressShared and add tests#25826

Merged
jkmassel merged 6 commits into
trunkfrom
jkmassel/relocate-untested-extensions
Jul 23, 2026
Merged

Move five untested Foundation extensions to WordPressShared and add tests#25826
jkmassel merged 6 commits into
trunkfrom
jkmassel/relocate-untested-extensions

Conversation

@jkmassel

Copy link
Copy Markdown
Contributor

Continues the cross-platform WordPressShared work (#25825, #25815, #25344). Where those PRs moved extensions that already had a test in KeystoneTests, this one goes after app-layer Foundation extensions that had no test at all — so a test-driven sweep never surfaced them. Each is a pure-Foundation leaf that belongs in the library layer; relocating it into WordPressShared makes it reusable and, for the first time, exercisable under the root swift test cross-platform gate. Every move lands with a new Swift Testing suite.

Moved (each with a new suite in WordPressSharedTests)

Extension What it does New tests
Calendar day/weekday helpers (NSCalendar+Helpers) day counting + localized↔unlocalized weekday-index conversions 3 — the standout; fiddly modular arithmetic that was completely untested
Bool.stringLiteral "true"/"false" 1
Data.hexString bytes → lowercase hex (used to stringify the push token) 3
Progress.discreteCompletedProgress() an already-complete Progress 1
@Atomic NSLock-backed property wrapper 1

+9 XCTest-equivalent cases under the root swift test gate, all green.

Caller changes

Nine files pick up an import WordPressShared; the members used by the app are made public (Calendar's were already public, and @Atomic exposes only the wrapper/init/wrappedValueload/store stay internal). Two of the five needed no caller changes at all — Bool.stringLiteral's three call sites and Data.hexString's one real caller already import WordPressShared.

Note: Data.hexString is distinct from the similarly named UIColor.hexString in WordPressUI — that one is unrelated and untouched.

Considered but not moved

Pattern.swift (the Pattern<Element> closure combinators) looked like a relocation candidate, but it's still used by PingHubManager, so it stays put.

Test plan

  • swift test from the repo root: 86 tests / 16 suites, 0 failures — the five new suites (BoolStringRepresentationTests, DataHexStringTests, ProgressHelpersTests, AtomicTests, CalendarHelpersTests) run under the cross-platform gate.
  • xcodebuild build-for-testing -scheme WordPress -testPlan WordPressUnitTests -destination 'generic/platform=iOS Simulator': ** TEST BUILD SUCCEEDED ** — the app and every module/test target still compile, with all nine caller imports resolving.
  • swiftlint: 0 violations across the 19 changed files.

Related

jkmassel added 5 commits July 22, 2026 15:01
A pure-Foundation leaf that lived in the app with no test coverage.
Relocating it to WordPressShared makes it reusable and exercisable under
the root `swift test` cross-platform gate, with a new Swift Testing
suite. All three existing call sites already import WordPressShared, so
no caller changes are needed.
A pure-Foundation leaf (Data → hexadecimal string, used to stringify the
push notification device token) that lived in the app untested. The
similarly named UIColor.hexString in WordPressUI is a separate extension
and is unchanged. The one real caller, PushNotificationsManager, already
imports WordPressShared. Adds a Swift Testing suite.
…tests

A pure-Foundation leaf, untested, used by the media exporters to hand
back an already-complete Progress. Relocated to WordPressShared; the five
exporter call sites pick up an import WordPressShared. Adds a Swift
Testing suite.
A pure-Foundation, NSLock-backed property wrapper, untested, used by two
Blog Dashboard helpers. Relocated to WordPressShared with the wrapper,
its init, and wrappedValue made public (load/store stay internal); both
call sites pick up an import WordPressShared. Adds a Swift Testing suite.
A pure-Foundation leaf (day counting and localized<->unlocalized weekday
index conversions), untested despite fiddly modular arithmetic. It
already leaned on WordPressShared's normalizedDate(), so relocation is
natural; the two call sites pick up an import WordPressShared. Adds a
Swift Testing suite covering the weekday-index conversions and day
counting. Keeps the legacy NSCalendar+Helpers file name.
@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 Number33382
VersionPR #25826
Bundle IDorg.wordpress.alpha
Commit6ad9013
Installation URL0sr9id5pvleb0
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 Number33382
VersionPR #25826
Bundle IDcom.jetpack.alpha
Commit6ad9013
Installation URL2oc66k87hu4c0
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

🤖 Build Failure Analysis

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

@jkmassel jkmassel added Testing Unit and UI Tests and Tooling [Type] Tech Debt labels Jul 22, 2026
@jkmassel jkmassel added this to the 27.2 milestone Jul 22, 2026
@jkmassel
jkmassel force-pushed the jkmassel/relocate-untested-extensions branch from eeabaf8 to af107f1 Compare July 22, 2026 21:43
Adds edge-case coverage to the suites introduced earlier in this branch,
worked up via an analyze-then-adversarially-verify pass over each one:

- Data.hexString: high bytes (no sign extension), byte order, a full
  0...255 nibble reference, a hex round-trip, a UTF-8 reference vector,
  and a non-zero-start-index slice.
- Progress: distinct-instance independence, determinacy, not
  cancelled/paused, and that discreteCompletedProgress() does not attach
  to a current parent (the reason it uses discreteProgress).
- @atomic: a 10k-iteration concurrent readers/writers stress test, value
  copy independence, reference identity, and Optional/nil round-trip.
- Calendar: round-trip identity and in-range invariants across all seven
  firstWeekday values, a Saturday-start case, multi-span day counts,
  negative (future) counts, and time-of-day normalization.

Bool.stringLiteral is a two-value mapping already fully covered, so it
gets nothing. Two proposals were corrected during review: the @atomic
concurrency assertion moved outside the concurrentPerform closure (GCD
threads don't carry Swift Testing's task-local context), and the Progress
parent check now asserts before resignCurrent, which otherwise
auto-completes the pending unit.
@jkmassel
jkmassel force-pushed the jkmassel/relocate-untested-extensions branch from af107f1 to 6ad9013 Compare July 22, 2026 23:26
@jkmassel
jkmassel added this pull request to the merge queue Jul 23, 2026
Merged via the queue into trunk with commit e78ab6f Jul 23, 2026
28 checks passed
@jkmassel
jkmassel deleted the jkmassel/relocate-untested-extensions branch July 23, 2026 20:09
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