mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-10 21:07:03 +01:00
check_shell_coverage.sh has existed for a while and was never in .pre-commit-config.yaml, so nothing ran it: a new shell library with no suite beside it could land freely. Wiring it was unaffordable while the gate measured a jail-run 100% bar (--all took over 600s). After578c4a6cdropped that, --all is 0.31s and the per-file mode this hook uses is milliseconds, so it goes in. Also fixes a bug578c4a6cintroduced: the failure path still interpolated ${COVERAGE_BAR}, which that commit deleted, so every rejection printed "COVERAGE_BAR: unbound variable" and advised a 100% line-coverage bar that no longer exists. The message now describes what is enforced. Three libs blocked the wiring -- meta/scripts/lib/shell_coverage_{bar, case_runner,jail_setup}.sh, the code that BUILDS the jail, and so the one corner of the repo the jail cannot measure itself. They are pure file-writers, so they get a suite that calls them against a temp $JAIL and asserts on what was written: 48 assertions, nothing mounted, no unshare, no kcov. Several assertions check that an emitted file contains an UNEXPANDED ${BASH_SOURCE} or $1 -- the whole point of the quoted heredocs the jail relies on. Written as single-quoted literals that is SC2016 on every line, so the needles compose the dollar from an exported constant instead. No suppressions were added. check_shell_coverage.sh --all: 3 BLOCK -> 0 BLOCK hook, repo-wide: 0.16s new suite: 48 assertions, green Proved the ratchet still bites: an untested lib dropped into mtk_root/lib is refused with "needs: .../tests/run_all.sh". Probe removed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PJrqKERAo5QUeEHWS5Asgp
27 lines
821 B
Bash
Executable File
27 lines
821 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# lib/tests/run_all.sh — run every shell-coverage tooling test in one go, and
|
|
# exit non-zero if any of them fails.
|
|
#
|
|
# These three libs build and measure the coverage jail, so they are the one
|
|
# corner of the repo the jail cannot check itself. The tests are pure: they
|
|
# call the file-writing functions against a temp $JAIL and assert on what was
|
|
# written. Nothing here mounts, unshares, or runs kcov.
|
|
set -uo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
failed=0
|
|
for test_script in "${SCRIPT_DIR}"/test_*.sh; do
|
|
printf '\n### %s\n' "$(basename "$test_script")"
|
|
if ! "$test_script"; then
|
|
failed=$((failed + 1))
|
|
fi
|
|
done
|
|
|
|
if [[ $failed -gt 0 ]]; then
|
|
printf '\n%d test file(s) FAILED\n' "$failed"
|
|
exit 1
|
|
fi
|
|
|
|
printf '\nAll shell-coverage tooling test files passed.\n'
|