testsAndMisc/phone_focus_mode/lib/tests
Krzysztof kuhy Rudnicki 3ddc13f671 focus_ctl: split 1091 -> 171 + 8 siblings, one per enforcer
The largest file in phone_focus_mode, and the last one blocking deploy.sh:
splitting it grows deploy.sh's two hardcoded lists, so those lists are only
final now. All 55 functions moved verbatim.

Three while-read loops were audited before extraction. Two call pm in their
bodies and moved untouched. The third, iter_whitelist_packages, is fed by a
pipe from printf and reads nothing from stdin -- already safe, and now said
so in ctl_usage.sh's header so the distinction is not lost by a later editor
who has only read the warning in daemon_apps.sh.

136 assertions and 22 mutations, all killed. Three survived the first run
and every one was a defect in MY OWN tests, not in the subject:

  - cmd_status carries a THIRD copy of the Haversine, and I had asserted
    only that it printed "some number". A wrong Earth radius sailed through.
    Now the value is checked against a seeded fix ~4.3 km from home.
  - the two whitelist filters were each tested with input the OTHER filter
    also rejects, so either could be deleted with nothing failing. Fixed
    with a punctuation-free undotted token (only the dot check rejects it)
    and a dotted token carrying an illegal character (only the charset check
    does), making each independently observable.

That last investigation turned up dead code: the `#*)` case arm is provably
equivalent, because `set -- $line` makes a comment's first token "#", which
the dot check already rejects. Removed rather than covered by a test that
cannot fail.

Coverage is NOT 100% and the real numbers are in the evidence: 41.79% to
92.98% across the eight, up from 5-22%. Unlike the daemon split, most of
what remains is genuinely untested -- the per-enforcer status blocks that
print mount state, APK hashes and offload settings, each needing its own
device fixture. The mutations prove the assertions that exist are load-
bearing; they do not prove those branches work.

jscpd checked in a clean worktree at 1.57%: eight files each carrying a
near-identical start/stop/status trio is exactly what that gate is for, so
the tests drive the trios through tables instead of repeating them.

Two drift hazards recorded, not fixed: ctl_is_curfew_now duplicates
daemon_location.sh's is_curfew_now (pinned by an agreement test across every
boundary minute), and cmd_status's awk is the third Haversine.

Over-cap count 17 -> 16. deploy.sh is the last one here.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
2026-08-17 17:46:04 +02:00
..
adb_test_harness.sh phone_focus_mode: split test_adb_common.sh 287 -> 134 + 105 2026-08-17 10:34:55 +02:00
backup_capture_harness.sh phone_backup: split 333 -> 229 + 114, with the library at 100% 2026-08-17 16:02:25 +02:00
ctl_cases_commands.sh focus_ctl: split 1091 -> 171 + 8 siblings, one per enforcer 2026-08-17 17:46:04 +02:00
ctl_cases_curfew.sh focus_ctl: split 1091 -> 171 + 8 siblings, one per enforcer 2026-08-17 17:46:04 +02:00
ctl_cases_daemon.sh focus_ctl: split 1091 -> 171 + 8 siblings, one per enforcer 2026-08-17 17:46:04 +02:00
ctl_libs_harness.sh focus_ctl: split 1091 -> 171 + 8 siblings, one per enforcer 2026-08-17 17:46:04 +02:00
curfew_net_cases_chain.sh curfew_enforcer: split 367 -> 244 + 156, net layer at 100% 2026-08-17 16:18:05 +02:00
curfew_net_cases_lifecycle.sh curfew_enforcer: split 367 -> 244 + 156, net layer at 100% 2026-08-17 16:18:05 +02:00
curfew_net_harness.sh curfew_enforcer: split 367 -> 244 + 156, net layer at 100% 2026-08-17 16:18:05 +02:00
daemon_cases_apps.sh focus_daemon: split 543 -> 206 + 165 + 140 + 94, with 110 tests 2026-08-17 16:54:04 +02:00
daemon_cases_location.sh focus_daemon: split 543 -> 206 + 165 + 140 + 94, with 110 tests 2026-08-17 16:54:04 +02:00
daemon_cases_state.sh config.sh: split 571 -> 250, with a fingerprint that actually works 2026-08-17 17:17:02 +02:00
daemon_cases_status.sh config.sh: split 571 -> 250, with a fingerprint that actually works 2026-08-17 17:17:02 +02:00
daemon_cases_sweep.sh focus_daemon: split 543 -> 206 + 165 + 140 + 94, with 110 tests 2026-08-17 16:54:04 +02:00
daemon_libs_harness.sh focus_daemon: split 543 -> 206 + 165 + 140 + 94, with 110 tests 2026-08-17 16:54:04 +02:00
dns_iptables_harness.sh meta: measurable shell coverage, and dns_iptables.sh at 100% 2026-08-17 15:29:08 +02:00
hosts_cases_assert.sh hosts_enforcer: split 421 -> 207 + 166 + 91, both libs at 100% 2026-08-17 16:30:56 +02:00
hosts_cases_cache.sh hosts_enforcer: split 421 -> 207 + 166 + 91, both libs at 100% 2026-08-17 16:30:56 +02:00
hosts_cases_magisk.sh hosts_enforcer: split 421 -> 207 + 166 + 91, both libs at 100% 2026-08-17 16:30:56 +02:00
hosts_cases_mount.sh hosts_enforcer: split 421 -> 207 + 166 + 91, both libs at 100% 2026-08-17 16:30:56 +02:00
hosts_libs_harness.sh hosts_enforcer: split 421 -> 207 + 166 + 91, both libs at 100% 2026-08-17 16:30:56 +02:00
monitor_cases_health.sh monitor: backfill to 100% coverage, fixing two defects it exposed 2026-08-17 15:54:04 +02:00
monitor_cases_policy.sh monitor: backfill to 100% coverage, fixing two defects it exposed 2026-08-17 15:54:04 +02:00
monitor_harness.sh monitor: backfill to 100% coverage, fixing two defects it exposed 2026-08-17 15:54:04 +02:00
test_adb_common.sh phone_focus_mode: split test_adb_common.sh 287 -> 134 + 105 2026-08-17 10:34:55 +02:00
test_adb_trusted.sh phone_focus_mode: split test_adb_common.sh 287 -> 134 + 105 2026-08-17 10:34:55 +02:00
test_backup_capture.sh phone_backup: split 333 -> 229 + 114, with the library at 100% 2026-08-17 16:02:25 +02:00
test_ctl_libs.sh focus_ctl: split 1091 -> 171 + 8 siblings, one per enforcer 2026-08-17 17:46:04 +02:00
test_curfew_net.sh curfew_enforcer: split 367 -> 244 + 156, net layer at 100% 2026-08-17 16:18:05 +02:00
test_daemon_libs.sh config.sh: split 571 -> 250, with a fingerprint that actually works 2026-08-17 17:17:02 +02:00
test_dns_iptables.sh meta: measurable shell coverage, and dns_iptables.sh at 100% 2026-08-17 15:29:08 +02:00
test_hosts_libs.sh hosts_enforcer: split 421 -> 207 + 166 + 91, both libs at 100% 2026-08-17 16:30:56 +02:00
test_magisk_service.sh feat(phone-focus): add recovery workflow, automation scripts, and docs 2026-05-01 19:07:27 +02:00
test_monitor.sh monitor: backfill to 100% coverage, fixing two defects it exposed 2026-08-17 15:54:04 +02:00
test_tether_enforcer.sh tether_enforcer: split 267 -> 182 + 103, and grow both deploy lists 2026-08-17 14:38:53 +02:00