test: add CI-safe unit coverage across LockIMEKit#10
Conversation
Raise unit-test coverage of Sources/LockIMEKit so every non-system file reaches at least 90% line coverage on a non-exempt basis. The new tests are mock-driven — no Carbon/TIS, NSWorkspace, Accessibility, SMAppService, or wall-clock access — so they pass on headless CI, and each was seen failing before passing. The single source change extracts the pure register/unregister decision out of LoginItemController.setEnabled into a testable `action(desiredEnabled:current:)`, so its branches can be covered without registering a real login item. The switch maps one-to-one to the previous if/else, so the launch-at-login behavior is unchanged. Signed-off-by: Kevin Cui <bh@bugs.cc>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
Summary by CodeRabbit
WalkthroughThis PR adds a pure decision-logic helper to 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
Comment |
What
Raises unit-test coverage of
Sources/LockIMEKitso every non-off-limits file reaches ≥90% line coverage on a non-exempt basis. All new tests are CI-safe (no hardware/system access) and were written red-first.Per-file coverage (xccov, before → after)
Rules/LockConfiguration.swiftLocalization/SupportedLanguage.swiftUpdates/UpdateChannel.swiftLockEngine/LockEngine.swiftLogging/LogStore.swiftLockEngine/InputSourceChangeObserver.swiftLoginItem/LoginItemController.swiftOverall non-exempt coverage across non-off-limits files: 547/567 = 96.5%.
How
MockInputSourceProvider,MockFrontmostMonitor,MockBrowserURLProvider). No Carbon/TIS, NSWorkspace, Accessibility, SMAppService, or wall-clock access — passes on headless CI, never mutates machine state.LoginItemController.setEnabledinto a testableaction(desiredEnabled:current:). Theswitchmaps 1:1 to the previousif/else— launch-at-login behavior is unchanged, and the new symbols areinternal(invisible to the app module).System-call exemptions (remaining uncovered lines)
Each is genuinely unexercisable CI-safe; verified by an adversarial audit pass:
LoginItemController38/40/53-65 —SMAppService.mainAppstatus/register/unregister.LockEngine86-93 — private handlers wired only to the internally-constructed (non-injected)InputSourceChangeObservers, fired only by CFNotificationCenter.InputSourceChangeObserver47-54 — the C callback body; only real distributed-notification delivery invokes it.LogStore22-23 (realapplicationSupportDirectorywrite) and 43/57 (SwiftDatasave/deleteerror catch — can't force a throw on a valid container).The 5 off-limits shims (
TISInputSourceProvider,FocusNudge,AppActivationMonitor,InstalledAppsScanner,AccessibilityBrowserURLReader) were not touched.Verification
make testgreen — 133 tests, 0 failures, incl.LocalizationGuardTests.