mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-24 15:06:17 +01:00
Compare commits
No commits in common. "bcb3e59fa71d684de75f38e98d3f447580652913" and "d277369aca2877c798b6331a3210eb37f7a0a4c6" have entirely different histories.
bcb3e59fa7
...
d277369aca
@ -5,6 +5,10 @@
|
||||
|
||||
## The scoping answers are SETTLED. Do not re-ask them.
|
||||
|
||||
The user answered these explicitly on 2026-08-22. An earlier session built a
|
||||
_presence-based, lib-only ratchet_ instead — the opposite of every answer. It
|
||||
has since been converted. **Do not re-propose the ratchet.**
|
||||
|
||||
| Question | Answer |
|
||||
| ------------------ | ---------------------------------------------------- |
|
||||
| **Scope** | Repo-wide gate. NOT a ratchet. |
|
||||
@ -14,148 +18,166 @@
|
||||
| **Order** | Tests first; arm the gate only once 100% is reached. |
|
||||
| **Target picking** | Hardest first. |
|
||||
|
||||
Because the gate arms last, it never freezes the repo. That ordering is what
|
||||
makes this safe.
|
||||
Because the gate arms last, it never freezes the repo — there is nothing left
|
||||
to block by the time it turns on. That ordering is what makes this safe.
|
||||
|
||||
## What is already true (verify, do not redo)
|
||||
|
||||
```bash
|
||||
git log --oneline -5 # 0091608b, d277369a, 154b4166, b91be309 on main
|
||||
grep -vc '^#\|^$' meta/shell-coverage-allowlist.txt # 103 (was 105)
|
||||
git log --oneline -5 # bca70b67, 61ff5eac, b7523d16, 0e843c2a on main
|
||||
bash meta/scripts/check_file_length.sh --all # all within 250 lines
|
||||
grep -vc '^#\|^$' meta/shell-coverage-allowlist.txt # 105
|
||||
```
|
||||
|
||||
- **The allowlist went 105 -> 103.** `unity_handler.sh` and
|
||||
`transcribe_venv.sh` both measure **100%** and are OFF it, verified through
|
||||
`check_shell_coverage.sh` itself with the exemption deleted.
|
||||
- **`meta/scripts/shell_coverage_jail.sh`** measures a script's coverage while
|
||||
it runs **for real** in a user+mount namespace. New this session:
|
||||
`--fail-on-case-error` (default OFF). Without it a suite with a failing
|
||||
assertion exits 0.
|
||||
- **A suite declares its jail needs in a `jail_args` file** beside its
|
||||
`run_all.sh`. `ci_mirror.sh`, `shell-tests.yml` and `is_covered()` all read
|
||||
it. No marker = the suite runs bare.
|
||||
- **CI is green.** `shell-tests.yml` SKIPS jail_args-marked suites with a
|
||||
printed reason: kcov is not packaged for Ubuntu 24.04 and upstream ships no
|
||||
binary. The pre-push `ci-mirror` hook runs them for real instead.
|
||||
it runs **for real** inside a user+mount namespace. This is the campaign's
|
||||
core tool. **100% needs NO source changes and NO suppressions.**
|
||||
- **`meta/scripts/check_shell_coverage.sh`** now enforces a **measured 100%
|
||||
bar** (it was a presence check that an empty suite could satisfy). It is
|
||||
**deliberately NOT wired into any hook yet.**
|
||||
- **jscpd was already over its own 2% threshold at 2.45%** and would have
|
||||
rejected every commit staging a `.sh` file. Vendored `.venv/` shell alone
|
||||
accounted for it (2.50% -> 1.67%); `lib/tests/` is also excluded now (1.47%).
|
||||
- **5 commits are unpushed.** Push them when convenient.
|
||||
|
||||
### Measured so far (always through `run_all.sh` — see below)
|
||||
### Measured so far
|
||||
|
||||
| lib | coverage | state |
|
||||
| ------------------------- | ------------------- | ------------- |
|
||||
| `dot_resolver_install.sh` | **39/39 = 100.00%** | off allowlist |
|
||||
| `unity_handler.sh` | **32/32 = 100.00%** | off allowlist |
|
||||
| `transcribe_venv.sh` | **53/53 = 100.00%** | off allowlist |
|
||||
| `rpi_nc_ca.sh` | 72/73 = 98.63% | allowlisted |
|
||||
| `transcribe_pkgmgr.sh` | 49/50 = 98.00% | allowlisted |
|
||||
| `nc_php.sh` | 84/85 = 98.82% | allowlisted |
|
||||
| `clean_audio_filters.sh` | 83/93 = 89.25% | allowlisted |
|
||||
| `transcribe_deps.sh` | 48/52 = 92.31% | allowlisted |
|
||||
| `aw_autostart.sh` | 68/82 = 82.93% | allowlisted |
|
||||
| `dwm_config.sh` | 35/73 = 47.95% | allowlisted |
|
||||
| `rpi_nc_install.sh` | 10/88 = 11.36% | MIS-MEASURED |
|
||||
| lib | coverage |
|
||||
| ------------------------- | -------------------------------------------- |
|
||||
| `dot_resolver_install.sh` | **39/39 = 100.00%** (off the allowlist) |
|
||||
| `nc_php.sh` | 84/85 = 98.82% (still exempt) |
|
||||
| `rpi_nc_install.sh` | 10/88 = 11.36% — **MIS-MEASURED, see below** |
|
||||
|
||||
Two directories now have harnesses:
|
||||
`single_use/features/lib/tests/` (jailed) and
|
||||
`single_use/misc/testsAndMisc-bash/lib/tests/` (no jail, 118 assertions).
|
||||
Suites are green: **28 + 30 + 29 = 87 assertions, 0 failures.**
|
||||
|
||||
## Start here
|
||||
|
||||
Highest-scored remaining, all in `features/lib/` where a harness exists:
|
||||
The hardest remaining, scored on root ops + system writes + destructive calls.
|
||||
**44 of the 105 allowlisted libs sit in `features/lib/`, where a harness
|
||||
already exists** — that directory is the cheapest place to keep going.
|
||||
|
||||
```
|
||||
score lines file
|
||||
4x ~ linux_configuration/scripts/single_use/features/lib/*.sh (41 left)
|
||||
22 libs linux_configuration/scripts/single_use/fixes/lib/ (no harness yet)
|
||||
9 libs phone_focus_mode/lib/ (no harness yet)
|
||||
53 221 linux_configuration/scripts/single_use/features/lib/dwm_config.sh
|
||||
51 241 linux_configuration/scripts/single_use/features/lib/aw_autostart.sh
|
||||
51 179 linux_configuration/scripts/single_use/features/lib/rpi_nc_ca.sh
|
||||
50 92 linux_configuration/scripts/single_use/misc/testsAndMisc-bash/lib/transcribe_deps.sh
|
||||
```
|
||||
|
||||
### The invocation that works
|
||||
|
||||
```bash
|
||||
bash -c '
|
||||
ja=(); while IFS= read -r l; do ja+=("$l"); done \
|
||||
< <(grep -v "^#\|^$" linux_configuration/scripts/single_use/features/lib/tests/jail_args)
|
||||
timeout 300s bash meta/scripts/shell_coverage_jail.sh \
|
||||
bash meta/scripts/shell_coverage_jail.sh \
|
||||
--subject linux_configuration/scripts/single_use/features/lib/tests/run_all.sh \
|
||||
"${ja[@]}" --measure <lib>.sh --min 1 --fail-on-case-error -- ""'
|
||||
--bind /etc --bind /usr/local/bin --bind /var --bind /root \
|
||||
--seed-dir /var/www/nextcloud --seed-dir /var/lib \
|
||||
--seed-dir /etc/php/8.2/apache2 --seed-dir /etc/php/8.2/mods-available \
|
||||
--seed-dir /etc/apache2/sites-available \
|
||||
--seed-file /etc/php/8.2/apache2/php.ini \
|
||||
--measure <lib>.sh --min 100 --timeout 90s -- ""
|
||||
```
|
||||
|
||||
**Always measure through `run_all.sh`, never a single test file.** That is the
|
||||
subject `is_covered()` builds, and the runner's number can be LOWER than the
|
||||
same suite's own — `rpi_nc_ca.sh` is 100% alone and 98.63% through the runner.
|
||||
Reporting the single-file figure is reporting a number the gate will not agree
|
||||
with.
|
||||
|
||||
## Traps that cost real time this session
|
||||
|
||||
- **`--fail-on-case-error` or you are flying blind.** The jail suppresses a
|
||||
suite's stdout entirely, so assertions can fail invisibly. Always pass it.
|
||||
- **To find WHERE a suite dies, use an `exit <n>` sentinel.** Temporarily end
|
||||
the suite with `exit 42` at a chosen point; the jail surfaces the code. This
|
||||
is the only way to tell a tracing failure from an aborted suite.
|
||||
- **`rm -f "$TEST_TMPDIR/bin/foo"` does NOT hide foo.** bash caches executable
|
||||
locations, so `command -v foo` keeps succeeding. Both harnesses now ship
|
||||
`_t_unstub`, which also runs `hash -r`. Three assertions in this repo were
|
||||
asserting the opposite of their own names because of this.
|
||||
- **A prepended stub dir cannot hide a real binary either.** If the host truly
|
||||
has the tool (`pacman`, `aw-qt`, `/usr/lib/libsndfile.so`), REPLACE PATH or
|
||||
jail it. Otherwise the "not installed" case tests nothing.
|
||||
- **A stub must materialise what the real tool creates.** A record-only stub
|
||||
in a `[[ ! -s $file ]]` fallback chain silently exercises the NEXT branch.
|
||||
- **A top-level stub function SHADOWS the subject's own** for every later
|
||||
assertion. Put redefinitions in a subshell.
|
||||
- **`shfmt` reformats after your own check passes** — re-check the 250-line cap
|
||||
after staging.
|
||||
- **Commits exceed a 2-minute foreground timeout.** Use `run_in_background`.
|
||||
- **Two-strike rule.** Two failed attempts at the same line -> stop, document,
|
||||
keep the working state.
|
||||
`--bind` what a subject **writes**; **never** bind what it **reads**. Binding
|
||||
`/usr/local/bin` cut `pacman_wrapper.sh` from 75.00% to 28.95%, because it
|
||||
sources its sibling libs from there. **Never `--bind /tmp`** — the jail's own
|
||||
working dir lives there and the run dies with "cases: No such file".
|
||||
|
||||
## THE OPEN PROBLEM — read before trusting any number
|
||||
|
||||
**kcov silently under-reports, and it is contagious across processes in one
|
||||
jail.** `rpi_nc_ca.sh` measures 100% alone but 98.63% through `run_all.sh`;
|
||||
bisection shows `test_dwm_config.sh` running first is what costs it line 141.
|
||||
`dwm_config.sh` reports 47.95% while an `exit 43` sentinel proves four of its
|
||||
functions run to completion.
|
||||
**kcov mis-measures `rpi_nc_install.sh`.** It reports 10/88 = 11.36%,
|
||||
recording lines 13-54 and nothing after — but the code past line 54 provably
|
||||
runs: `/root/.nextcloud_db_password` and
|
||||
`/etc/apache2/sites-available/nextcloud.conf` both exist after a run, and all
|
||||
29 assertions pass.
|
||||
|
||||
**One artifact is CONFIRMED:** continuation lines inside a multi-line quoted
|
||||
argument (a `perl -0777 -pe '...'` block) are counted as statements that never
|
||||
run — the wrong denominator. **Six other hypotheses are DISPROVEN** (heredocs,
|
||||
`$(...)`, stdin-reading stubs, `cd` relocation, heredoc-into-stubbed-external,
|
||||
and the exec-ing `sudo` shim / pipelines). Full details and the disproof list
|
||||
are in `docs/shell-split-verification.md`. **Do not re-run those.**
|
||||
Three hypotheses were each tested against a minimal reproduction and
|
||||
**DISPROVEN** — do not retry them:
|
||||
|
||||
The failure is one-directional: it only ever under-reports, so it can keep a
|
||||
lib on the allowlist but can never promote an untested one. That is why the
|
||||
campaign can continue around it. **Never "fix" a number by weakening a test.**
|
||||
1. kcov traces correctly **past a heredoc**.
|
||||
2. kcov traces correctly **into a `$(...)` command substitution**.
|
||||
3. kcov traces correctly **past a heredoc-fed stub reading stdin via `$(cat)`**.
|
||||
|
||||
The cause is unknown. **This is a hole in the campaign's primary instrument.**
|
||||
The other two libs in the same directory measure sensibly, so it is not
|
||||
universal, but nobody has bounded which subjects it affects. If a suite's
|
||||
assertions pass while its percentage looks absurd, suspect this before
|
||||
suspecting the tests. **Never "fix" a number by weakening a test.**
|
||||
|
||||
## Traps that cost real time — all still live
|
||||
|
||||
- **Check assertion RESULTS, not just the coverage percentage.** The committed
|
||||
`nc_php` suite shipped **2 failing assertions** because an earlier session
|
||||
measured coverage and never read the output. Both were test bugs: the cron
|
||||
entry arrives on `crontab`'s **stdin**, not argv, and `configure_mariadb`'s
|
||||
stdout is eaten by `db_password=$(...)`. Run the suite and read it.
|
||||
- **A top-level stub function SHADOWS the subject's own function** for every
|
||||
later assertion. Doing this for a phase-order test dropped coverage
|
||||
83.53% -> 57.65% **while the tests still reported passing**, because they
|
||||
were exercising the stubs. Put such redefinitions in a **subshell**.
|
||||
- **A stub for a piped-into command must drain stdin**, or the writer takes
|
||||
SIGPIPE and the suite aborts under `set -e`. If its output feeds `grep -v`,
|
||||
it must also **emit a line** — `grep` exits 1 on no match and `pipefail`
|
||||
propagates that.
|
||||
- **A stub must materialise what the real tool creates.** `rm -rf
|
||||
/var/www/nextcloud` followed by a record-only `unzip` leaves the later `cd`
|
||||
with nothing to enter; the function returns 1 and `set -e` aborts the suite
|
||||
from inside a command substitution **with no stderr at all**.
|
||||
- **`sudo` cannot work inside a userns** (`setresuid` -> EINVAL). The jail
|
||||
supplies a pass-through that drops flags and `exec`s. Do not add `sudo` to
|
||||
`DEFAULT_SHIMS` — recording-and-exiting would skip the very writes the
|
||||
suites exist to assert on.
|
||||
- **The jail needs its own `passwd`/`group`/`nsswitch`**, or `id -u "$USER"`
|
||||
fails and aborts the subject under `set -e` before anything interesting.
|
||||
- **`--map-root-user` alone does not grant `/etc` writes.** `CAP_DAC_OVERRIDE`
|
||||
in a userns only covers files whose owner uid is mapped in; the bind-mount
|
||||
over the write target is what makes the write land.
|
||||
- **`shfmt` (run by the pre-commit hook) reformats and can push a file over
|
||||
the 250-line cap** _after_ your own check passed. It also rewrites `case`
|
||||
arms onto separate lines, so exact-match patches written against the old
|
||||
layout silently fail to apply. Re-check the cap after staging.
|
||||
- **Commits exceed a 2-minute foreground timeout.** Run `git commit` with
|
||||
`run_in_background: true` and read the output file.
|
||||
- **Two-strike rule.** Two failed attempts at the same line -> stop, document
|
||||
it, keep the working state. `nc_php.sh` line 111 (the `crontab -l ||`
|
||||
first-run fallback) hung the suite twice and is deliberately left uncovered.
|
||||
|
||||
## Rules that will bite you
|
||||
|
||||
- **No suppressions, ever.** Fix SC2016/SC2155 at the source.
|
||||
- **No suppressions, ever.** SC2155 and SC2016 were both fixed at the source
|
||||
rather than disabled; do the same.
|
||||
- **Every commit touching code needs evidence** in
|
||||
`docs/superpowers/evidence/<slug>-<date>.json` (validate with
|
||||
`docs/superpowers/evidence/<slug>-<date>.json` (schema: `intent`, `scope`,
|
||||
`changes[]`, `verification[]` each with `command`/`result`/**`evidence`**,
|
||||
`risks[]`, `rollback[]` — validate with
|
||||
`python3 meta/scripts/validate_evidence.py <file>`), **plus a contract** in
|
||||
`docs/superpowers/contracts/` once **>=4 code files** are staged.
|
||||
- **Put the MEASURED number in it**, never a rounded or hoped-for one.
|
||||
- **Stage narrowly.** A concurrent session had 8 unrelated files in the shared
|
||||
index this session; `git restore --staged` them, do not commit them.
|
||||
- **New test files need the exec bit** — and `git add --chmod=+x` only changes
|
||||
the INDEX. `chmod +x` the working tree too or the shebang hook fails.
|
||||
- **`CI_GREEN_SKIP=1`** is the documented escape hatch when THIS commit is the
|
||||
fix for a red baseline. It must also be exported for the pre-push mirror.
|
||||
- **Stage narrowly.** Pre-commit hooks restage files; a `git add` of one path
|
||||
once swept four unrelated files from a _concurrent session_ into a commit.
|
||||
Check `git diff --cached --name-only` before committing.
|
||||
- **New test files need the exec bit**: `git add --chmod=+x`.
|
||||
- Work directly on `main`. `git stash` and branch creation are blocked.
|
||||
- **Another Claude session may be working in this repo simultaneously.**
|
||||
- **Another Claude session may be working in this repo simultaneously.** One
|
||||
was on 2026-08-21/22. Check `git log` for commits you did not make before
|
||||
assuming the tree is yours.
|
||||
|
||||
## Not caused by this campaign
|
||||
|
||||
**`Python tests` CI has been failing since 2026-08-17** — `pip` hits
|
||||
`error: resolution-too-deep` installing `meta/requirements.txt`. It needs
|
||||
dependency pinning and is deliberately excluded from `check_ci_green.sh`. Do
|
||||
not fold it into Phase 3.
|
||||
`error: resolution-too-deep` installing `meta/requirements.txt`, on commits
|
||||
touching no Python. It needs dependency pinning, and is why `python-tests.yml`
|
||||
is deliberately **not** in `check_ci_green.sh`'s required list. Worth fixing on
|
||||
its own; do not fold it into Phase 3.
|
||||
|
||||
**The 2026-08-22 11:33 hard freeze was investigated and cleared.** No OOM, no
|
||||
hung task, no kernel message after 11:20; this campaign was idle at the time
|
||||
and left no residue. Steam crash-dumped two minutes prior on an RTX 3090.
|
||||
Correlation only — a hard hang leaves no log — but the jail was ruled out. Each
|
||||
jail case is now bounded by `timeout --kill-after=10s` with stdin closed.
|
||||
|
||||
## When the allowlist reaches zero
|
||||
|
||||
Only then, wire `check_shell_coverage.sh` into **pre-commit, pre-push and CI**.
|
||||
`is_covered()` now reads `jail_args` and passes `--fail-on-case-error`, so the
|
||||
gate is ready; what remains is the allowlist. Note it runs a full jailed suite
|
||||
per lib, so an `--all` sweep is minutes and belongs in CI, not a commit hook.
|
||||
Only then, wire `check_shell_coverage.sh` into **pre-commit, pre-push and CI**
|
||||
(all three — that was the answer). Hook mode costs **0.42s per file**, so a
|
||||
normal commit stays sub-second; a full `--all` sweep is minutes and belongs in
|
||||
CI.
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
{
|
||||
"title": "Make the coverage gate read jail_args and refuse a suite that dies partway",
|
||||
"objective": "Close the two review-found defects that let checks pass more easily than they should: is_covered() ignored the jail_args marker every other consumer reads, and bash's command hash cache made two 'tool is missing' assertions test the opposite of their names.",
|
||||
"acceptance_criteria": [
|
||||
"is_covered() reads the jail_args file beside a suite's run_all.sh, the same marker ci_mirror.sh and shell-tests.yml consume, so a suite declares its own mounts in exactly one place.",
|
||||
"A suite with no jail_args still gets the historical default binds, so nothing that passed before starts failing for lack of a marker.",
|
||||
"A jail_args that is present but empty is a hard error, never a silent skip.",
|
||||
"is_covered() passes --fail-on-case-error, so a suite that aborts partway fails the gate rather than being graded on the lines it reached before dying.",
|
||||
"NEGATIVE CONTROL: stripping the binds a suite needs must make the gate exit non-zero. Before this change both the working and the broken configuration exited 0.",
|
||||
"dot_resolver_install.sh, which is already off the allowlist, still clears the real gate afterwards -- the campaign's proof that 100% is reachable must survive the stricter check.",
|
||||
"Every 'tool is missing' assertion genuinely hides the tool: removal clears bash's hash table via a shared _t_unstub helper.",
|
||||
"No measured coverage figure moves as a result of either fix, and every existing assertion still passes.",
|
||||
"shellcheck clean with no suppressions; all files within the 250-line cap."
|
||||
],
|
||||
"out_of_scope": [
|
||||
"test_cco_state.sh's removal of beeper.orig: get_real_binary probes with [[ -f ]], which the hash cache does not affect.",
|
||||
"test_aw_autostart.sh's removal of aw-qt: the assertion runs in a subshell via $status_script, so the parent shell's cache is irrelevant.",
|
||||
"Arming check_shell_coverage.sh in any hook; that waits for allowlist-zero.",
|
||||
"The kcov under-report, which is tracked separately in docs/shell-split-verification.md."
|
||||
],
|
||||
"verifier": "bash meta/scripts/check_shell_coverage.sh on dot_resolver_install.sh must exit 0; replacing that directory's jail_args with `--bind /etc` alone must make the same command exit non-zero, and restoring it must return exit 0 with an empty git diff --stat. Plus the features/lib runner under --fail-on-case-error reporting zero case failures, and all four features libs re-measured at their pre-change figures."
|
||||
}
|
||||
@ -1,50 +0,0 @@
|
||||
{
|
||||
"intent": "Close two defects found in review that would each have made the campaign's guarantees hollow: is_covered() ignored the jail_args marker (so 44 features/lib libs could never reach 100% through the gate), and two suites unstubbed a tool with a bare `rm`, which bash's command hash cache makes a no-op.",
|
||||
"scope": [
|
||||
"meta/scripts/lib/shell_coverage_bar.sh: is_covered() reads jail_args and passes --fail-on-case-error",
|
||||
"linux_configuration/scripts/single_use/features/lib/tests/features_harness.sh: new _t_unstub helper",
|
||||
".../tests/test_dwm_config.sh and test_rpi_nc_ca.sh: switched to _t_unstub",
|
||||
"Non-goal: test_cco_state.sh's `rm` of beeper.orig -- get_real_binary probes with `[[ -f ]]`, which the hash cache does not affect, so that test is sound"
|
||||
],
|
||||
"changes": [
|
||||
"GATE DEFECT: is_covered() hardcoded `--bind /etc --bind /usr/local/bin --bind /var/lib` and never read the jail_args file that ci_mirror.sh and shell-tests.yml both consume. The features/lib suite needs /usr/local/share and /etc/pki and ABORTS under set -e without them -- yet the coverage number still printed, because kcov had already recorded whatever the dead run reached. The gate would have graded a lib on a suite that never finished.",
|
||||
"is_covered() now reads the marker, falls back to the historical defaults when a suite has none, fails closed on a present-but-empty marker, and passes --fail-on-case-error so a suite that dies partway fails the gate instead of being scored on its stump.",
|
||||
"HASH-CACHE DEFECT: the _t_unstub helper written for the transcribe harness was needed in features_harness.sh too. Two assertions were vacuous -- test_dwm_config.sh's 'verify still reports when dwm is absent' and test_rpi_nc_ca.sh's uname removal after the macOS branch, where a cached uname would have left every later branch running under a faked Darwin.",
|
||||
"This was found by review rather than by a failing test, which is the point: both defects made checks PASS more easily, so nothing went red."
|
||||
],
|
||||
"verification": [
|
||||
{
|
||||
"command": "bash meta/scripts/check_shell_coverage.sh .../dot_resolver_install.sh",
|
||||
"result": "pass",
|
||||
"evidence": "exit 0 -- the lib that is already OFF the allowlist still clears the real gate now that the gate reads the marker and enforces case failure."
|
||||
},
|
||||
{
|
||||
"command": "NEGATIVE CONTROL: replace jail_args with `--bind /etc` alone, re-run the gate, restore",
|
||||
"result": "pass",
|
||||
"evidence": "gate exit=1 with the binds stripped, exit=0 after restoring. Before this commit BOTH cases exited 0 -- the gate could not fail on an aborting suite. git diff --stat on jail_args is empty afterwards."
|
||||
},
|
||||
{
|
||||
"command": "re-measure all four features libs after the _t_unstub fix",
|
||||
"result": "pass",
|
||||
"evidence": "dot_resolver_install.sh 39/39 = 100.00% (unchanged -- its off-allowlist clearance is sound with real absence enforced), dwm_config.sh 47.95%, rpi_nc_ca.sh 98.63%, aw_autostart.sh 82.93%. No figure moved."
|
||||
},
|
||||
{
|
||||
"command": "the features/lib runner under --fail-on-case-error after the change",
|
||||
"result": "pass",
|
||||
"evidence": "0 case failures -- every assertion still passes with the tools genuinely absent rather than cached."
|
||||
},
|
||||
{
|
||||
"command": "grep -rn 'rm -f \"$TEST_TMPDIR/bin/' --include='test_*.sh' linux_configuration/",
|
||||
"result": "pass",
|
||||
"evidence": "Four hits audited. Two fixed; test_aw_autostart.sh's runs in a subshell via $status_script so the parent's cache is irrelevant; test_cco_state.sh probes with [[ -f ]], not command -v."
|
||||
}
|
||||
],
|
||||
"risks": [
|
||||
"is_covered() now runs the full jailed suite per lib with --fail-on-case-error, so a directory whose suite is slow makes the gate slower per file. Hook mode was measured at 0.42s/file before; a jailed suite is seconds, which is why an --all sweep belongs in CI rather than a commit hook.",
|
||||
"A suite that legitimately has no jail_args gets the historical default binds. If such a suite later needs a mount it will abort and now correctly fail the gate -- loudly, which is the intended direction, but it is a new way for the gate to go red."
|
||||
],
|
||||
"rollback": [
|
||||
"git revert the commit; is_covered() returns to hardcoded binds with no case-failure check, and the two suites return to vacuous absence assertions.",
|
||||
"After rollback, re-run the negative control: it should exit 0 with the binds stripped, confirming the fail-open behaviour is back."
|
||||
]
|
||||
}
|
||||
@ -86,16 +86,6 @@ _t_stub() {
|
||||
chmod +x "$TEST_TMPDIR/bin/$1"
|
||||
}
|
||||
|
||||
# Remove a stub AND forget it. bash caches executable locations in a hash
|
||||
# table, so `command -v foo` keeps succeeding after foo is deleted until the
|
||||
# table is cleared -- silently turning every "tool is missing" test into a
|
||||
# "tool is present" test that asserts the opposite of its own name. Measured:
|
||||
# without the `hash -r` the removed stub is STILL FOUND.
|
||||
_t_unstub() {
|
||||
rm -f "$TEST_TMPDIR/bin/$1"
|
||||
hash -r
|
||||
}
|
||||
|
||||
_t_called() {
|
||||
if [[ -f "$TEST_TMPDIR/calls.log" ]] && grep -q "$1" "$TEST_TMPDIR/calls.log"; then
|
||||
_t_pass "$2"
|
||||
|
||||
@ -176,7 +176,7 @@ _t_has "$verify_out" 'dwm version:' "verify reports the dwm version"
|
||||
_t_has "$verify_out" 'xsession registered' "verify confirms the xsession is registered"
|
||||
|
||||
# --- verify: tolerates a missing dwm binary ---------------------------------
|
||||
_t_unstub dwm
|
||||
rm -f "$TEST_TMPDIR/bin/dwm"
|
||||
missing_out="$(verify 2>&1)" || true
|
||||
_t_has "$missing_out" 'dwm version:' "verify still reports when dwm is absent (dwm -v exits 1)"
|
||||
|
||||
|
||||
@ -141,7 +141,7 @@ chmod +x "$TEST_TMPDIR/bin/uname"
|
||||
mac_out="$(phase_install_ca 2>&1)"
|
||||
_t_has "$mac_out" 'Detected macOS' "the macOS branch is selected when uname reports Darwin"
|
||||
_t_has "$mac_out" 'system keychain' "the macOS branch reports the keychain install"
|
||||
_t_unstub uname
|
||||
rm -f "$TEST_TMPDIR/bin/uname"
|
||||
|
||||
# --- phase_install_ca: certutil reports the CA is ALREADY installed ---------
|
||||
# `certutil -L` emitting a line containing "Nextcloud" takes the else branch.
|
||||
|
||||
@ -35,38 +35,10 @@ is_covered() {
|
||||
command -v kcov >/dev/null 2>&1 || return 0
|
||||
command -v unshare >/dev/null 2>&1 || return 0
|
||||
|
||||
# A suite declares the mounts and seeds it needs in a `jail_args` file
|
||||
# beside its run_all.sh -- the same marker ci_mirror.sh and
|
||||
# shell-tests.yml read. Hardcoding flags here was a latent gate failure:
|
||||
# the features/lib suite needs /usr/local/share and /etc/pki, and without
|
||||
# them it ABORTS partway under `set -e`. The coverage number still printed
|
||||
# (kcov had already recorded the lines the dead run reached), so the gate
|
||||
# would have passed a lib whose suite never finished.
|
||||
local jail_args=()
|
||||
local args_file
|
||||
args_file="$(dirname "$suite")/jail_args"
|
||||
if [[ -f "$args_file" ]]; then
|
||||
local arg
|
||||
while IFS= read -r arg; do
|
||||
jail_args+=("$arg")
|
||||
done < <(grep -v '^#\|^$' "$args_file" || true)
|
||||
if [[ ${#jail_args[@]} -eq 0 ]]; then
|
||||
echo "Error: jail_args is present but empty: $args_file" >&2
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
# No marker: the suite runs without needing anything mounted, so give
|
||||
# it the historical defaults rather than nothing.
|
||||
jail_args=(--bind /etc --bind /usr/local/bin --bind /var/lib)
|
||||
fi
|
||||
|
||||
# --fail-on-case-error: a suite that dies partway must fail the gate, not
|
||||
# be graded on however many lines it managed to reach first.
|
||||
"$REPO_ROOT/meta/scripts/shell_coverage_jail.sh" \
|
||||
--subject "$suite" \
|
||||
"${jail_args[@]}" \
|
||||
--bind /etc --bind /usr/local/bin --bind /var/lib \
|
||||
--measure "$(basename "$path")" \
|
||||
--min "$COVERAGE_BAR" \
|
||||
--fail-on-case-error \
|
||||
-- "" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user