test: cover the edge cases the suite was missing#129
Merged
Conversation
Adds ~58 assertions for previously-untested branches and degenerate inputs, all at the run.sh layer (stub-driven, hardware-independent, bash 3.2-safe) per tests/README.md — no new files, SHELL_FILES unchanged. Behaviours now covered: - check_prerequisites: the whole jq-bootstrap (apt/dnf/pacman/none/brew/ no-brew/already-present) — was entirely untested - install_dependencies: the dnf and pacman branches + the no-manager warn-not-abort path + the apt-cache-present linux-tools branch - install_service reboot-gate (#audit A2): enable-but-NOT-start when a reboot is pending, restart on rebuild, start on steady state, plus CPUPOWER_PATH substitution in ExecStartPre - compile_xmrig drops the clone (rm -rf) on a commit mismatch (#18) - config-gen round-trips: bracketed IPv6 url, single-pool tls, empty ACCESS_TOKEN -> JSON null - restore of a corrupt / config-less archive: fails AND leaves the existing config.json untouched (no silent clobber) - uninstall without --yes aborts cleanly on 'n' and reverts nothing - mac_start guard (no built worker -> "run setup first"); mac_stop launchd-owned delegation - numeric degenerate inputs: _median/_stddev/_mean on empty/single sample; _watts_from_energy backwards counter w/ no wrap-max; the no-power efficiency fallbacks in _accept_better and _autotune_score - compute_build_jobs sub-2GB floor; the 1G fstab line on a fresh write; the rest of the xmrig.service hardening block Verified: make lint clean; make test 664/664; make coverage 91.34% (floor 80); suite passes 687/687 on a real Ubuntu 24.04 / bash 5.2 rig. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
A coverage-gap pass over the suite: an audit found behaviours, branches, and degenerate inputs in
rigforge.shthat no test exercised, and this fills them. ~58 new assertions,tests/run.shonly — no new files,SHELL_FILESunchanged.Every addition lands at the layer
tests/README.mdprescribes: logic / config-gen / command behaviour, driven by PATH stubs, hardware-independent, bash-3.2-safe. Each is the lowest layer that proves the behaviour honestly — nothing here needed a new/etceffect, macOS-native tool, or real hardware beyond what the existing layers already cover. Each test fails if the logic breaks (e.g. the commit-mismatch test asserts the clone directory is gone, not just that the error prints; the reboot-gate test assertsstart/restartare absent from the systemctl call log).Behaviours now covered
check_prerequisitesinstall_dependenciesapt-cache-presentlinux-tools-<rel>branchinstall_service(#audit A2)Restart=always); restart on rebuild; start on steady state;CPUPOWER_PATHresolved inExecStartPrecompile_xmrig(#18)rm -rf xmrig) so the next run starts cleantls:truereaches config.json; emptyACCESS_TOKEN→ JSONnullrestoreuninstall--yes, answeringnaborts cleanly and reverts nothingmac_startno-worker guard ("run setup first");mac_stoplaunchd-owned delegation_median/_stddev/_meanon empty & single sample;_watts_from_energybackwards counter with no wrap-max → empty (not negative); no-power fallback in_accept_betterand_autotune_scorecompute_build_jobssub-2GBmax<1→1floor; 1G fstab line on a fresh write; the rest of thexmrig.servicehardening blockResidual gaps (deliberately NOT in this PR — the real completeness note)
These are gaps a stub can't honestly close; recording them rather than pretending they're covered:
e2e-realconfirms the enabled-but-stopped state; the across-reboot start is a human check).vm.nr_hugepagesvalue wiring — the reserved count is still proven only byproposed-grub.sh's isolated math; the sysctl stub swallows-w. The actual reservation is proven bye2e-realon real hardware. A CI logging-sysctl assert would only re-derive the math without proving anything new, so it's intentionally left to the release gate.tune_kernel/etc/modulesMSR fallback content — the primarymodules-load.dpath is covered in-container; the fallback (systems withoutmodules-load.d) is asserted only via the uninstall pre-seed. Low-value residual gap.Bugs
None. Every branch exercised behaves correctly — the suite passing against previously-untested paths is itself the evidence. This PR adds coverage, it does not change
rigforge.sh.Verification
make lint— clean (shellcheck + shfmt)make test— 666/666 localmake coverage— 91.60% total (rigforge.sh91.45%,util96.15%) vs floor 80; kcov ran the full suite (689 checks). Patch-coverage gate is N/A — the change touches onlytests/run.sh, so there are zero changed lines in the instrumentedrigforge.sh/util.miner-0) — validation was fully stubbed, so the running miner was never disturbed and the rig was left as found.🤖 Generated with Claude Code