Skip to content

fix(tests): DST-safe time helpers for BolusCalculator and ScheduledBasalInference - #40

Merged
mountrcg merged 1 commit into
devfrom
fix/sync-39-dst-tests
Oct 25, 2026
Merged

mountrcg merged 1 commit into
devfrom
fix/sync-39-dst-tests

Conversation

@mountrcg

Copy link
Copy Markdown
Owner

fix(tests): DST-safe time helpers for BolusCalculator and ScheduledBasalInference (post-#39 CI repair)

Source branch: fix/sync-39-dst-tests → target: dev
Baseline: dev 54e76a96e5e6ac4bd6968ec98a2b165c36d23fd5 (direct parent of the repair commit)
Repair commit: 09f07d0860a137693e34342275670fac32493958
Diff scope: 2 test files, +5 / −4 (TrioTests/BolusCalculatorTests/BolusCalculatorTests.swift, TrioTests/CoreDataTests/ScheduledBasalInferenceTests.swift)

Summary

Post-merge CI repair for sync PR #39 (sync/trio-2026-10-25 → dev, merge 804801c50, merged as b5e9d2f2).
PR #39 fixed the four stale OpenAPSSwift parity goldens, but the dev CI run on its merge result still fails
the full iOS unit-test job. The cause is not the merge: two test helpers in the Trio test target compute their
fixtures with elapsed-seconds-from-start-of-day arithmetic, which breaks on the Europe/Berlin DST fallback day
(2026-10-25 is a 25-hour day and the Trio Tests scheme pins TZ=Europe/Berlin). Both helpers predate the
sync and are test-only.

This PR contains only those two helper corrections. Production code, localization, project file, schemes,
parity goldens and branch history are untouched, and the pre-existing FPU expectation repair already on dev
is not modified.

CI evidence (the failure this repairs)

GitHub Actions run 40171219998 on dev head 54e76a96e — [DO NOT RUN] Automated unit tests:

Job Result
Algorithm Package (swift test) PASS (1m7s)
Run Unit Tests (iOS simulator) FAIL — xcodebuild test exit 65, 28m2s

The full-suite job built successfully and failed only in Run tests, in the two areas repaired here:
BolusCalculatorTests resolved the 07:00 scheduled basal setting to 90 instead of 100, and
ScheduledBasalInferenceTests produced the wrong segment count for the fallback day, including an
index-out-of-range after the unexpected count. 54e76a96e itself carried only the Tai FPU expectation update
(TrioTests/CoreDataTests/CarbsStorageTests.swift), so it did not include these two corrections.

The two corrections

1. ScheduledBasalInferenceTests.time(_:_:)

Before: startOfDay(for: Date()).addingTimeInterval(hour * 3600 + minute * 60) — on a 25-hour fallback day
the accumulated seconds land an hour off the intended wall-clock hour, shifting every fixture in the sweep
relative to the schedule boundaries it is meant to hit.

After: Calendar.current.date(bySettingHour:minute:second:of:) with a start-of-day fallback — fixtures are
built at the requested wall-clock hour/minute, matching how production ScheduledBasalInference builds and
compares its schedule bounds.

2. BolusCalculatorTests.getCurrentSettingValue(for:at:)

Before: minute-of-day derived as dateComponents([.minute], from: startOfDay, to: date).minute — an elapsed
count that is one hour short on the fallback day, so the 07:00 lookup fell into the previous schedule entry
(90 instead of 100).

After: minute-of-day derived from dateComponents([.hour, .minute], from: date) as hour * 60 + minute —
wall-clock semantics, consistent with production minutesOfDay.

Both helpers therefore keep schedule-lookup semantics through the fallback and the spring transition for the
daytime values the tests exercise. They still anchor to the current date, so this is not deterministic
coverage of every time zone or ambiguous local time — it removes the DST dependence, it does not add DST
regression coverage.

Deliberately not part of this PR

  • TrioTests/CoreDataTests/CarbsStorageTests.swift — the Tai-specific FPU split expectation (16 × 2.7 g in
    Tai processFPU semantics) was already repaired on dev in 54e76a96e and is unchanged here.
  • No production, localization, project.pbxproj, scheme or parity-golden changes.
  • No change to 804801c50 / b5e9d2f2 history: the repair commit's direct parent is the current dev
    baseline, so the branch adds exactly one commit on top of dev and nothing is rewritten.

Verification evidence (narrow, pre-PR)

Reviewer and coder evidence is local and narrow by design; it does not replace PR CI.

  • Provenance/scope (independent review): single commit, direct parent exactly 54e76a96e, complete
    baseline-to-HEAD diff limited to the two helpers (5 insertions, 4 deletions), git diff --check clean, no
    staged or committed change outside TrioTests/.
  • ScheduledBasalInferenceTests: 11 tests passed in the coder's selector run (xcresult
    Test-Trio Tests-2026.10.25_09-50-57-+0100.xcresult).
  • BolusCalculatorTests/testGetCurrentSettingValue(): the coder's selector was written without the trailing
    (), so it never executed that test; the reviewer re-ran it explicitly against the same build and verified
    1 passed, 0 failed/skipped (xcresult Test-Trio Tests-2026.10.25_09-57-57-+0100.xcresult). Reported as
    11 scheduled-basal passes plus this separately verified bolus pass — not as one combined run.
  • The unrelated working-tree changes present before the review (Trio Watch App.xcscheme,
    Trio Watch Complication Extension.xcscheme, Localizable.xcstrings, plus this untracked draft) are
    excluded and must not be staged with the branch.

Release gate

Full PR CI is the release gate: both Algorithm Package (swift test) and Run Unit Tests must be green on
the pushed fix/sync-39-dst-tests head before merge. The narrow local runs above only show that the two
failing areas are repaired; they do not cover the rest of the iOS suite.

Merge checklist

  • Push fix/sync-39-dst-tests (single commit 09f07d086, parent 54e76a96e) — nothing pushed yet.
  • Confirm the pushed-head diff is exactly the two TrioTests/ files (+5 / −4).
  • Confirm Algorithm Package (swift test) and Run Unit Tests both green on the PR head.
  • Merge into dev (Robert only; the orchestrator never merges).
  • Re-check the resulting dev CI run to confirm the two pre-sync helper defects are closed.

…rence tests

Use calendar wall-clock construction instead of elapsed-seconds-from-start-of-day math, so test fixtures resolve to the intended hour/minute across the Europe/Berlin DST fallback transition.
@mountrcg
mountrcg merged commit fc7090e into dev Oct 25, 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