mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 17:54:03 +01:00
The split shipped verbatim-proven and green, but measuring it afterwards
showed the tests barely touched it: monitor.sh 44.44%, the policy probes
7.69%, and the health probes never loaded at all. Every _check_* decides
whether phone enforcement is reported as healthy, so an untested probe is
an enforcement failure that reports itself as fine.
The mock stubs adb_root_shell at the function boundary rather than putting
a fake adb on PATH: the probes never invoke adb, they call a function from
adb_common.sh, so a PATH stub would never be consulted. Dispatch is by
pattern, not exact string, because the real commands embed awk programs
with escaped $2, nested quotes and 2>/dev/null redirections.
Two defects the new tests found:
- _mon_escape_json never escaped double quotes. Written as
${escaped//"/\"}, bash reads the bare quote as opening a quoted string,
so the pattern silently degraded to `/\` with an empty replacement. Any
check message containing a quote produced invalid JSON.
- monitor_print_format_warning's multi-line array literal and
collect_snapshot's `{ ... } >file` group held 12 lines that no test
could ever cover: kcov instruments the continuation lines and the
closing brace, but bash only reports a statement at its first line.
Reproduced in an isolated 9-line case before changing anything.
Assertions are mutation-proofed: 18 mutations of the probes' status
decisions, 18 killed. The first run had one survivor -- the repairable
flag was asserted nowhere -- now pinned in both directions.
monitor.sh 104/104 = 100.00% (was 44.44%)
monitor_checks_policy.sh 65/65 = 100.00% (was 7.69%)
monitor_checks_health.sh 79/79 = 100.00% (was 0%)
test_monitor.sh 82 passed, 0 failed (was 9)
Cases live in two sourced files purely to stay under the 250-line cap;
test_monitor.sh remains the single entry point, so one coverage command
still measures all three subjects. Over-cap count unchanged at 22.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
21 lines
2.5 KiB
JSON
21 lines
2.5 KiB
JSON
{
|
|
"title": "Backfill monitor.sh and both probe libraries to 100% line coverage",
|
|
"objective": "Close the pre-existing test debt the monitor.sh split made visible: monitor.sh at 44.44%, monitor_checks_policy.sh at 7.69% and monitor_checks_health.sh never loaded at all. Every _check_* probe decides whether phone enforcement is reported as healthy, so an untested probe is an enforcement failure that reports itself as fine.",
|
|
"acceptance_criteria": [
|
|
"bash meta/scripts/shell_coverage.sh phone_focus_mode/lib/tests/test_monitor.sh <subject> exits 0 at its default 100% minimum for each of monitor.sh, monitor_checks_policy.sh and monitor_checks_health.sh.",
|
|
"bash phone_focus_mode/lib/tests/test_monitor.sh reports a test count strictly greater than the 9 it reported before this change, with 0 failures.",
|
|
"Every assertion is mutation-proofed: a scripted run breaks each _check_* status decision in turn and requires the suite to fail, with zero survivors.",
|
|
"bash meta/scripts/check_file_length.sh --all reports no more over-cap files than before this change (22), so no new file crosses the 250-line cap.",
|
|
"shellcheck passes on each touched file individually, with no -x and no disable directive, since the pre-commit hook reads each file standalone.",
|
|
"No suppression of any kind is added: no shellcheck disable, no lowered coverage threshold, no skipped assertion.",
|
|
"The mock reaches the probes through the adb_root_shell function, not a PATH stub, so adb_common.sh's device-detection and locking surface stays out of the test."
|
|
],
|
|
"out_of_scope": [
|
|
"Deploying to the phone or otherwise verifying against a real device; there is no device in this session and the probes are proven with stubs, hashes and real runs instead.",
|
|
"Splitting any of the other brief-scoped files (phone_backup.sh, curfew_enforcer.sh, hosts_enforcer.sh, focus_daemon.sh, config.sh, deploy.sh, focus_ctl.sh), which are separate commits.",
|
|
"Fixing test_magisk_service.sh, which hangs identically at HEAD and is unrelated to the monitor seam.",
|
|
"Changing what any probe reports to the user beyond the two defects fixed here."
|
|
],
|
|
"verifier": "bash phone_focus_mode/lib/tests/test_monitor.sh (expects 82 passed, 0 failed), plus bash meta/scripts/shell_coverage.sh phone_focus_mode/lib/tests/test_monitor.sh {monitor.sh,monitor_checks_policy.sh,monitor_checks_health.sh} each at 100.00%, plus the mutation run at 18 killed / 0 survived, plus bash meta/scripts/check_file_length.sh --all still showing 22 files, plus pre-commit run --files on the touched files."
|
|
}
|