mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 13:27:47 +01:00
First of the 16 untested fixes/lib libs. Measured 37/37 = 100.00% through lib/tests/run_all.sh, twice, the second run at --min 100 (exit 0), then removed from the allowlist and confirmed with the real gate and no exemption. Adds two reusable pieces rather than a per-family harness clone: - lib_test_core.sh -- PASS/FAIL tally, _t_eq/_t_contains/_t_lacks, a mktemp -d sandbox wiped on EXIT, a FAKE_BIN stub dir on PATH, and _t_stub/_t_unstub. _t_unstub runs `hash -r`: deleting a stub file alone does not drop bash's cached executable path, so the real binary would never be reached again. - bt_harness.sh -- sources the core, sources the real scripts/lib/common.sh for the production log_*/has_cmd helpers (verified inert at source time), and redefines _btctl and apply_fix verbatim from fix_bluetooth.sh, since those live in the entry script rather than in any lib. Same trade-off pacman_hook_stall_harness.sh already makes with log_size. pacman_hook_stall_harness.sh is deliberately left alone: its six libs are already off the allowlist, i.e. gated at 100% with no exemption, so refactoring it onto the new core would risk banked work for no gain. jscpd reads 1.6% against the hook's own flags, and **/lib/tests/** is excluded from that scan anyway, so the duplication budget is not at stake. _t_only_path exists because every tool these libs call (usbreset, pactl, lsusb, ...) genuinely exists on an Arch desktop: a prepended stub dir cannot exercise a "not installed" branch, so those cases drop PATH to FAKE_BIN alone. The three coverage runs were made in a detached worktree: a second session was writing to this repo concurrently, and the jail aborts on any working-tree delta during a run. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
54 lines
5.0 KiB
JSON
54 lines
5.0 KiB
JSON
{
|
|
"intent": "Test linux_configuration/scripts/single_use/fixes/lib/bt_report.sh to 100% line coverage and take it off the shell-coverage allowlist, continuing the fixes/lib coverage campaign.",
|
|
"scope": [
|
|
"linux_configuration/scripts/single_use/fixes/lib/tests/lib_test_core.sh (new shared assertion/sandbox primitives)",
|
|
"linux_configuration/scripts/single_use/fixes/lib/tests/bt_harness.sh (new fix_bluetooth.sh family harness)",
|
|
"linux_configuration/scripts/single_use/fixes/lib/tests/test_bt_report.sh (new, 24 assertions)",
|
|
"meta/shell-coverage-allowlist.txt (one line removed)",
|
|
"Non-goal: refactoring pacman_hook_stall_harness.sh, whose six libs are already gated at 100% with no exemption",
|
|
"Non-goal: the remaining 15 untested fixes/lib libs, handled in later commits"
|
|
],
|
|
"changes": [
|
|
"Added lib_test_core.sh: PASS/FAIL tally, _t_eq/_t_contains/_t_lacks assertions, a mktemp -d sandbox wiped on EXIT, a FAKE_BIN stub dir on PATH, and _t_stub/_t_unstub. _t_unstub runs `hash -r`, because removing a stub file alone does not drop bash's cached executable path.",
|
|
"Added bt_harness.sh: sources lib_test_core.sh, sources the real scripts/lib/common.sh for the production log_*/has_cmd helpers (verified inert at source time), and redefines _btctl and apply_fix verbatim from fix_bluetooth.sh since those live in the entry script rather than in any lib.",
|
|
"Added _t_only_path, which drops PATH to FAKE_BIN alone: every tool these libs call (usbreset, pactl, lsusb, ...) genuinely exists on this host, so a prepended stub dir cannot exercise a 'not installed' branch.",
|
|
"Added test_bt_report.sh covering show_instructions (both the known-MAC and <MAC>-placeholder branches) and dump_diagnostics (populated output, the (none loaded)/(rfkill not available) fallbacks, the empty-TARGET_MAC skip, and the (device not known) arm).",
|
|
"Removed linux_configuration/scripts/single_use/fixes/lib/bt_report.sh from meta/shell-coverage-allowlist.txt."
|
|
],
|
|
"verification": [
|
|
{
|
|
"command": "bash linux_configuration/scripts/single_use/fixes/lib/tests/run_all.sh",
|
|
"result": "pass",
|
|
"evidence": "test_bt_report.sh: 24 passed, 0 failed. All fixes lib test files passed -- the eight pre-existing pacman_hook_stall suites stay green alongside the new file."
|
|
},
|
|
{
|
|
"command": "bash meta/scripts/shell_coverage_jail.sh --subject linux_configuration/scripts/single_use/fixes/lib/tests/run_all.sh --measure bt_report.sh --min 1 --fail-on-case-error -- \"\"",
|
|
"result": "pass",
|
|
"evidence": "bt_report.sh: 37/37 lines = 100.00%. Measured through run_all.sh, the subject is_covered() builds. No 'outside kcov's line set' lines were reported, so the figure covers every statement kcov instrumented."
|
|
},
|
|
{
|
|
"command": "bash meta/scripts/shell_coverage_jail.sh --subject linux_configuration/scripts/single_use/fixes/lib/tests/run_all.sh --measure bt_report.sh --min 100 --fail-on-case-error -- \"\"",
|
|
"result": "pass",
|
|
"evidence": "bt_report.sh: 37/37 lines = 100.00%, exit code 0. Second matching run at the --min 100 bar, so a shortfall would have been a non-zero exit rather than a number to misread."
|
|
},
|
|
{
|
|
"command": "bash meta/scripts/check_shell_coverage.sh linux_configuration/scripts/single_use/fixes/lib/bt_report.sh",
|
|
"result": "pass",
|
|
"evidence": "'check_shell_coverage.sh: every checked shell library meets the coverage bar', exit 0, run with the allowlist line already removed so the lib had no exemption."
|
|
},
|
|
{
|
|
"command": "jscpd --pattern '**/*.sh' --min-lines 14 --min-tokens 25 --threshold 2 (the pre-commit hook's exact flags)",
|
|
"result": "pass",
|
|
"evidence": "444 files, 27 clones, 933 duplicated lines = 1.6%, under the 2% threshold. The hook already excludes **/lib/tests/** and **/tests/**, so the shared-core harness design carries no duplication risk."
|
|
}
|
|
],
|
|
"risks": [
|
|
"bt_harness.sh copies _btctl and apply_fix from fix_bluetooth.sh, so a change to either in the entry script would leave the harness stale. This is the same trade-off pacman_hook_stall_harness.sh already makes with log_size, and is preferable to moving those helpers into a lib, which would reintroduce a cross-file-global seam.",
|
|
"The three coverage runs were executed in a detached git worktree under the scratchpad, because a second Claude session was concurrently writing to this repo (phone_focus_mode/config.sh, focus_owner/) and the jail aborts on any working-tree delta during a run. The measurement subject and libs were identical to HEAD; only the tree's isolation differed."
|
|
],
|
|
"rollback": [
|
|
"git revert the commit; that restores the bt_report.sh line in meta/shell-coverage-allowlist.txt and deletes the three new test files together.",
|
|
"After rollback, run bash linux_configuration/scripts/single_use/fixes/lib/tests/run_all.sh and confirm the eight pacman_hook_stall suites still pass, then bash meta/scripts/check_shell_coverage.sh to confirm the gate is green with bt_report.sh exempt again."
|
|
]
|
|
}
|