testsAndMisc/linux_configuration/scripts/periodic_background/digital_wellbeing/lib/tests
Krzysztof kuhy Rudnicki 72e1b6a8b1 block_compulsive_opening: test the allow/block decision
21 assertions for cco_state.sh, the lib that decides whether a launch is
permitted. Coverage measured: 62/66 lines = 93.94%. The only uncovered lines
are kill_app's pkill/pkill -9 pair, which must never run in a test on a
machine whose apps are live. cco_wrapper/cco_install/cco_report stay at 0%:
every function in them moves system binaries, writes /etc/pacman.d/hooks or
kills processes.

The assertion that matters most is the one in the negative direction: a
PREVIOUS hour's stamp must NOT keep blocking. If that decision inverted, a
legitimately-closed app could never be reopened, and the failure would look
like the tool working. Both directions are pinned, plus the empty-stamp case
and stale suspend-marker cleanup.

Also generalises run_all.sh from test_leechblock_*.sh to test_*.sh. This
directory now holds suites for more than one entry script, and a prefix glob
silently skips every suite added after it — including inside the CI discovery
step added in fbec4656, which runs this file.

The harness asserts its own fixture is complete rather than letting a typo in
a global surface as a confusing unbound-variable from inside the code under
test. That check is also what makes the fixture's globals legible to
shellcheck, which cannot see them being read across the source boundary — a
real check that happens to remove SC2034, not a suppression.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F3PzGc75gBcdxP3PkHXGcV
2026-08-21 15:53:54 +02:00
..
cco_harness.sh block_compulsive_opening: test the allow/block decision 2026-08-21 15:53:54 +02:00
leechblock_harness.sh install_leechblock: first test suite for the split libs 2026-08-21 15:39:15 +02:00
run_all.sh block_compulsive_opening: test the allow/block decision 2026-08-21 15:53:54 +02:00
test_cco_state.sh block_compulsive_opening: test the allow/block decision 2026-08-21 15:53:54 +02:00
test_leechblock_browsers.sh install_leechblock: first test suite for the split libs 2026-08-21 15:39:15 +02:00
test_leechblock_fetch.sh install_leechblock: first test suite for the split libs 2026-08-21 15:39:15 +02:00