Compare commits

...

3 Commits

Author SHA1 Message Date
26afe4390c Cover aw_autostart.sh (82.93%), executing the script it generates
Some checks are pending
Pre-commit checks / pre-commit (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
A 25-assertion suite for aw_autostart.sh, second in the hardest-first order.

The generated i3blocks status script is asserted by RUNNING it against
stubbed pacman/pgrep across all four of its branches -- uninstalled,
installed-but-stopped, running, installed-via-package -- rather than by
grepping the heredoc's text. A heredoc that emits syntactically broken bash
passes a text check and fails in front of the user.

One assertion was silently testing nothing at first: aw-qt is genuinely
installed at /usr/bin/aw-qt on this host, so the "not installed" case found
the real binary through the PREPENDED stub dir. PATH is now REPLACED for that
one case. The suite went 24-passed-1-failed -> 25-passed-0-failed, and the
gate caught it rather than the number.

Measured 68/82 = 82.93%; it STAYS on the allowlist. The residue is the
`[[ $EUID -eq 0 ]]` false branches, which are unreachable inside the jail
because the process is uid 0 there, plus the documented kcov under-report --
an `exit 44` sentinel proves create_i3blocks_status runs to completion while
its lines 145-162 report zero hits. Third lib to show it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016sxxsDHWgdRhmdmzNMA6XM
2026-08-22 12:49:51 +02:00
768e73249d Cover dwm_config.sh and fix its unreachable upstream-drift warning
A 27-assertion suite for dwm_config.sh, the highest-scored remaining
allowlisted lib. It drives the lib for real inside the jail: rewriting dwm.c
with perl, appending to config.h, compiling with cc and installing into
/usr/local/bin. The generated content is asserted, not just the call.

LATENT BUG, found by writing the test: apply_fullscreen_confine_hook does
`on=$(grep -c 'pconfine-auto on' "$src")`, and grep -c exits 1 when the count
is zero. The caller runs `set -euo pipefail`, so the function aborted at that
line exactly when the count was zero -- which is precisely when the
"setfullscreen/unmanage were likely refactored upstream" warning three lines
below was the thing needed. The warn branch was dead code in the only
situation it exists for. Both call sites now use `|| true`, and the suite
asserts the warning fires.

Measured: dwm_config.sh 35/73 = 47.95%. It STAYS on the allowlist -- the bar
is 100% and it is measured, not asserted.

That number is an under-report. An `exit 43` sentinel proves build_install,
build_pointer_confine, write_session_files and verify all execute inside the
jail while kcov reports their bodies at zero hits. One kcov artifact is now
CONFIRMED against a minimal repro: continuation lines inside a multi-line
quoted argument (the `perl -0777 -pe '...'` blocks) are counted as
statements that never run, which is the wrong denominator. A sixth
hypothesis -- that the exec-ing sudo shim or a pipeline loses the trace --
was tested and disproven. The two-strike time-box on this hunt is spent;
docs/shell-split-verification.md records what is known, including the
exit-sentinel technique for telling a tracing failure from an aborted suite.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016sxxsDHWgdRhmdmzNMA6XM
2026-08-22 12:44:12 +02:00
6ebb3462ab CI: skip the kcov-jail suites instead of failing to install kcov
The previous commit added kcov to the shell-tests apt step on the assumption
it was packaged for Ubuntu. It is not -- CI went red in 34s on "E: Unable to
locate package kcov" -- and upstream ships no prebuilt binary either, so it
would have to be built from source on every run.

CI now skips jail_args-marked suites with a printed reason, the same trade
the arch-tests job already makes for Arch-only tests: declare what this
runner cannot do rather than pretend to check it. Enforcement is not lost --
ci_mirror.sh runs those suites through the real jail on every push, and that
gate is already proven to fail on a broken assertion. An empty jail_args is
still a hard failure.

Simulated over all six discovered runners: 5 PASS, 1 SKIP, none dropped.
Committed with CI_GREEN_SKIP=1, the ci-baseline-green hook's documented
escape hatch for a commit that IS the fix for the red baseline.

Also records the kcov instrument defect in docs/shell-split-verification.md.
rpi_nc_install.sh measures 11.36% while its 29 assertions pass and its writes
land on disk. Five hypotheses are now disproven against minimal
reproductions -- the three from the previous session, plus `cd`-relocation
and a heredoc piped into a stubbed external. The cause is still unknown, so
the rule is documented instead: a suspicious percentage means re-measure, not
re-write the test. The failure only ever under-reports, so it can keep a lib
on the allowlist but can never promote an untested one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016sxxsDHWgdRhmdmzNMA6XM
2026-08-22 12:31:36 +02:00
8 changed files with 611 additions and 94 deletions

View File

@ -12,11 +12,8 @@ jobs:
steps:
- uses: actions/checkout@v4
# kcov + unshare back shell_coverage_jail.sh, which the jail_args-marked
# lib/tests suites below run under. util-linux (unshare) is preinstalled;
# kcov is not.
- name: Install bats and kcov
run: sudo apt-get update && sudo apt-get install -y bats kcov
- name: Install bats
run: sudo apt-get update && sudo apt-get install -y bats
- name: Run bats suites
run: bats linux_configuration/tests/*.bats
@ -73,26 +70,31 @@ jobs:
for r in "${runners[@]}"; do
printf '\n=== %s ===\n' "$r"
# A suite that writes to real system paths ships a `jail_args`
# file and REFUSES to run bare; run it through the namespace jail
# with the flags it declares. Empty marker = configuration error.
# file and REFUSES to run bare, because running it bare would
# rewrite the runner's own /etc. It needs shell_coverage_jail.sh,
# which needs kcov -- and kcov is NOT packaged for Ubuntu 24.04
# ("E: Unable to locate package kcov", measured) and upstream
# ships no prebuilt binary, so it would have to be built from
# source on every run.
#
# These suites are therefore SKIPPED here and run for real by the
# ci-mirror pre-push hook on the developer machine, which has
# kcov. That is the same trade the arch-tests job below makes:
# declare what this runner cannot do rather than pretend to check
# it. A skip is announced, never silent.
#
# Empty marker = configuration error, still a hard failure.
args_file="${r%/run_all.sh}/jail_args"
if [ -f "$args_file" ]; then
mapfile -t jail_args < <(grep -v '^#\|^$' "$args_file" || true)
if [ "${#jail_args[@]}" -eq 0 ]; then
if ! grep -qv '^#\|^$' "$args_file"; then
printf 'FAIL %s (jail_args present but empty)\n' "$r"
failed=$((failed + 1))
continue
fi
# --min 0: this step gates on the ASSERTIONS, not on coverage.
# The jail's default --min 100 would otherwise measure the
# runner itself and fail on a number this step never asked for;
# the coverage bar belongs to check_shell_coverage.sh.
cmd=(bash meta/scripts/shell_coverage_jail.sh \
--subject "$r" "${jail_args[@]}" --min 0 --fail-on-case-error -- "")
else
cmd=("$r")
printf 'SKIP %s (needs the kcov jail; enforced by pre-push)\n' "$r"
continue
fi
if "${cmd[@]}"; then
if "$r"; then
printf 'PASS %s\n' "$r"
else
printf 'FAIL %s\n' "$r"

View File

@ -164,3 +164,61 @@ and `main`, which between them assign and read the same configuration globals.
Getting the entry under the cap needs `parse_args` restructured rather than
relocated — a refactor, not a verbatim move, so it is out of scope for this
method. Attempt it with a test harness, or accept an entry that stays over.
### kcov silently under-reports some subjects: never trust a percentage alone
`rpi_nc_install.sh` measures **10/88 = 11.36%** under
`meta/scripts/shell_coverage_jail.sh`, reporting lines 13–60 as covered and
everything from 61 on as not. The code past line 61 provably runs: the suite's
29 assertions pass, and both `/root/.nextcloud_db_password` (line 61) and
`/etc/apache2/sites-available/nextcloud.conf` (a heredoc ending at line 100)
exist on disk after a run. The two sibling libs in the same directory measure
sensibly, so this is not universal — and nobody has bounded which subjects it
affects.
**Five hypotheses have each been tested against a minimal reproduction and
DISPROVEN. Do not retry them:**
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)`**.
4. kcov traces correctly **past a `cd` that relocates the process** (including
`cd /tmp`, where the jail's own working dir lives) — lines after the `cd`
are recorded.
5. kcov traces correctly **past a heredoc piped into a stubbed external** —
`mysql -u root <<EOF` with a `cat >/dev/null` stub, under strict mode.
Lines after it are recorded.
**One CONFIRMED artifact (hypothesis 6), reproduced minimally:** kcov counts
the _continuation lines of a multi-line quoted argument_ as instrumentable
statements that never run. A `perl -0777 -i -pe '<newline>...s!a!b!;<newline>'`
block reports its inner lines at zero hits while the line after it is covered.
This accounts for `dwm_config.sh` lines 64-66 and 98-101, and for any
`done < <(...)` process substitution. These lines are **not statements**, so
the denominator is wrong, not the numerator.
That artifact does NOT explain the second pattern: ordinary statements inside
functions that provably execute. In `dwm_config.sh`, `build_install`,
`build_pointer_confine`, `write_session_files` and `verify` all run -- proved
with an `exit 43` sentinel placed after their assertions, which fired -- yet
their bodies report zero hits. `rpi_nc_install.sh` behaves the same way. A
sixth hypothesis (that the jail's `exec`-ing `sudo` shim or a pipeline loses
the trace) was tested minimally and **DISPROVEN**: both trace correctly.
The cause of that second pattern remains unknown. The practical rule:
> **A suspicious percentage means re-measure, not re-write the test.** If a
> suite's assertions pass while its number looks absurd, suspect the
> instrument before suspecting the tests. **Never "fix" a number by weakening
> an assertion.**
Note the failure is _silent and one-directional_: it under-reports, so it can
only ever keep a lib on the allowlist that deserves to come off. It cannot
promote an untested lib. That is why the campaign can continue around it.
**Use an `exit <n>` sentinel to tell the two apart.** The jail discards a
case's stdout, so a suite's own report is invisible; but a non-zero exit is
surfaced by `--fail-on-case-error`. Temporarily ending the suite with
`exit 42` at a chosen point turns "did execution reach here?" into a yes/no
the jail will answer. That is what proved the second pattern is a tracing
failure and not an aborted suite.

View File

@ -0,0 +1,43 @@
{
"intent": "Add a test suite for aw_autostart.sh (score 51), the second target in the hardest-first order. It stays on the allowlist at a measured 82.93%, below the 100% bar.",
"scope": [
"linux_configuration/scripts/single_use/features/lib/tests/test_aw_autostart.sh: new, 25 assertions across all 4 functions",
"Non-goal: no change to aw_autostart.sh -- unlike dwm_config.sh, no latent bug surfaced",
"Non-goal: removing the lib from the allowlist"
],
"changes": [
"The suite asserts the GENERATED i3blocks status script by EXECUTING it against stubbed pacman/pgrep, not by grepping its text. All four of its branches are covered: uninstalled, installed-but-stopped, running, and installed-via-package. A heredoc emitting syntactically broken bash would pass a text check and fail in front of the user; executing it is what catches that.",
"setup_autostart's idempotence is asserted directly -- a second run must leave exactly one `exec --no-startup-id aw-qt` line in the i3 config.",
"test_setup's two helpers (check_activitywatch_installed / check_activitywatch_running) live in the entry script above the source line. They are redefined per-assertion inside a SUBSHELL, per the documented trap: a top-level redefinition shadows the subject's own view for every later assertion and silently drops coverage while the tests still report passing."
],
"verification": [
{
"command": "run the suite outside the jail with SCRIPT_DIR rewritten",
"result": "pass",
"evidence": "'test_aw_autostart.sh: 25 passed, 0 failed'. An earlier run was 24/1: the 'AW uninstalled' case failed because aw-qt is genuinely installed at /usr/bin/aw-qt on this host, so a PREPENDED stub dir cannot hide it from `command -v`. Fixed by REPLACING PATH for that one case -- the assertion was silently testing nothing before."
},
{
"command": "shell_coverage_jail.sh --subject .../run_all.sh <jail_args> --measure aw_autostart.sh --min 1 --fail-on-case-error",
"result": "pass",
"evidence": "aw_autostart.sh: 68/82 lines = 82.93%, and no 'warn: case exited' line -- every assertion in all five suite files passes under the gate."
},
{
"command": "temporarily insert `exit 44` after the create_i3blocks_status assertions",
"result": "pass",
"evidence": "'warn: case exited 44' fired, proving create_i3blocks_status runs to completion even though kcov reports lines 145-162 at zero hits. Third lib exhibiting the documented under-report."
},
{
"command": "shellcheck on the new suite",
"result": "pass",
"evidence": "clean, no suppressions added."
}
],
"risks": [
"Lines 22, 148-149 and 205 are the `[[ $EUID -eq 0 ]]` false branches. Inside the jail the process IS uid 0, so the non-root halves are genuinely unreachable there -- a real limitation of measuring under the jail, not a gap in the tests. Reaching them needs a non-root run, which cannot write the paths the rest of the suite asserts on.",
"82.93% is an under-report of unknown magnitude for the same reason recorded in docs/shell-split-verification.md, so the lib stays allowlisted -- the conservative direction."
],
"rollback": [
"git revert the commit; the suite disappears and aw_autostart.sh returns to being untested but still allowlisted.",
"After rollback, confirm the allowlist still contains aw_autostart.sh so the gate's view of the lib is unchanged."
]
}

View File

@ -0,0 +1,40 @@
{
"intent": "Get the Shell tests workflow green again. The previous commit added `kcov` to its apt install step on the assumption it was packaged for Ubuntu; it is not, and CI went red in 34s on 'E: Unable to locate package kcov'. CI now skips jail-requiring suites with an announced reason, while the pre-push hook keeps running them for real on the developer machine, which has kcov.",
"scope": [
".github/workflows/shell-tests.yml: drop kcov from the install step; SKIP jail_args-marked suites with a printed reason",
"Non-goal: building kcov from source in CI -- minutes added to every run for a check the pre-push hook already performs on every push",
"Non-goal: any change to ci_mirror.sh, which runs these suites for real and is unaffected",
"Non-goal: weakening the empty-marker guard, which stays a hard failure"
],
"changes": [
"The assumption that kcov was apt-installable was inferred, not verified, and CI disproved it in 34 seconds. Upstream (SimonKagstrom/kcov v43) publishes no prebuilt binary asset either, so apt is not merely a packaging gap.",
"CI now declares what it cannot do rather than pretending to check it -- the same trade the arch-tests job already makes for Arch-only tests. The skip prints 'SKIP <runner> (needs the kcov jail; enforced by pre-push)' so it is announced, never silent.",
"The enforcement is not lost: ci_mirror.sh runs the marked suites through the real jail on every push, and that gate is already proven to fail on a broken assertion.",
"The empty-jail_args guard remains a hard failure, so a misconfigured marker still turns CI red instead of being skipped."
],
"verification": [
{
"command": "local simulation of the workflow step's loop over all six discovered runners",
"result": "pass",
"evidence": "5 PASS (scripts/lib, digital_wellbeing, hosts, periodic_background, utils), 1 SKIP (features/lib), failed=0. Every discovered runner is accounted for -- none silently dropped."
},
{
"command": "replace jail_args with comments+blank lines only, re-run the marker check, restore",
"result": "pass",
"evidence": "'FAIL (empty marker) -> correctly detected'. The fail-closed guard survives the rewrite; git diff --stat empty after restore."
},
{
"command": "gh run view 32567260903 --log-failed",
"result": "fail",
"evidence": "'E: Unable to locate package kcov' / 'Process completed with exit code 100' -- the failure this commit fixes, recorded as the measured reason for the redesign."
}
],
"risks": [
"The features/lib suite is now verified only by the pre-push hook, not by CI. A push made with --no-verify would land it unchecked. Acceptable because --no-verify is already forbidden by memories/git-rules.md, and the alternative (building kcov from source) taxes every CI run.",
"If a future contributor works on a machine without kcov, ci_mirror.sh's jailed branch cannot run there either; the jail already errors with 'Error: kcov is not installed' rather than passing silently."
],
"rollback": [
"git revert the commit; CI returns to attempting the kcov install and goes red again on the same apt error.",
"After rollback, confirm the shell-tests workflow fails at the install step, which is the symptom this commit removes."
]
}

View File

@ -0,0 +1,56 @@
{
"intent": "Add a test suite for dwm_config.sh, the highest-scored remaining allowlisted lib (score 53: root ops + system writes + destructive calls), and fix the latent bug that suite exposed. The lib stays on the allowlist because its measured coverage is 47.95%, below the 100% bar.",
"scope": [
"linux_configuration/scripts/single_use/features/lib/tests/test_dwm_config.sh: new, 27 assertions across all 9 functions",
"linux_configuration/scripts/single_use/features/lib/dwm_config.sh: fix the unreachable warn branch in apply_fullscreen_confine_hook",
"docs/shell-split-verification.md: record the CONFIRMED kcov artifact and the exit-sentinel technique",
"Non-goal: removing dwm_config.sh from the allowlist -- 47.95% is below the bar and the bar is measured, not asserted",
"Non-goal: further kcov root-cause hunting; the two-strike time-box is spent"
],
"changes": [
"The suite drives the lib for real: it rewrites dwm.c with perl, appends to config.h, compiles with cc and installs into /usr/local/bin, all inside the namespace jail. The generated CONTENT is asserted, not just the call.",
"LATENT BUG FIXED: apply_fullscreen_confine_hook computed `on=$(grep -c ...)`, and grep -c exits 1 when the count is zero. The caller runs `set -euo pipefail`, so the function aborted at that line precisely when the count was zero -- i.e. exactly when the 'upstream refactored these handlers' warning below it was the thing needed. The warn branch was dead code on a refactored upstream, which is the failure mode the comment says it exists to catch. Fixed with `|| true` at both call sites; the suite's 'warns when setfullscreen was refactored' assertion now passes and would fail if the fix were reverted.",
"SC2016 was fixed at the source (the failing-cc stub became a quoted heredoc that writes to stderr, which is where dwm_config redirects it) rather than suppressed."
],
"verification": [
{
"command": "shell_coverage_jail.sh --subject .../features/lib/tests/run_all.sh <jail_args> --min 0 --fail-on-case-error -- \"\"",
"result": "pass",
"evidence": "exit=0 across all four test files. This is machine-checked, not asserted: the same gate exits 1 on a deliberately broken assertion, verified earlier today."
},
{
"command": "shell_coverage_jail.sh ... --measure dwm_config.sh --min 1",
"result": "pass",
"evidence": "dwm_config.sh: 35/73 lines = 47.95%. The MEASURED number, not a rounded or hoped-for one. Below the 100% bar, so the lib stays on the allowlist."
},
{
"command": "reproduce the suite outside the jail with BIN_* redirected to a temp dir",
"result": "pass",
"evidence": "Every assertion through apply_fullscreen_confine_hook printed OK, including 'the hook warns when setfullscreen was refactored' -- the branch that was unreachable before the fix."
},
{
"command": "temporarily append `exit 43` after the verify assertions, run under --fail-on-case-error",
"result": "pass",
"evidence": "'warn: case exited 43' fired, proving build_install, build_pointer_confine, write_session_files and verify all execute inside the jail even though kcov reports their bodies at zero hits. The 47.95% is therefore an under-report, not missing tests."
},
{
"command": "minimal repro: perl -0777 with a multi-line quoted argument under kcov",
"result": "pass",
"evidence": "Lines 6,7,8 (inside the quoted block) report hits=0 while line 9 after it reports 1. CONFIRMS the multi-line-quoted-continuation artifact and accounts for dwm_config.sh lines 64-66 and 98-101."
},
{
"command": "shellcheck on the new suite; check_file_length.sh --all; prettier --check on the doc",
"result": "pass",
"evidence": "shellcheck clean with no suppressions; all files within 250 lines; markdown formatted."
}
],
"risks": [
"47.95% is an under-report of unknown magnitude, so the true figure is higher but unquantified. The lib stays allowlisted, which is the conservative direction: the defect can only keep a lib exempt, never promote an untested one.",
"The `|| true` on grep -c means a genuinely broken grep (missing file) now yields an empty count rather than aborting. The subsequent `[[ \"$on\" == 1 ]]` test fails closed into the warn branch, which is the intended behaviour.",
"meta/scripts/lib/shell_coverage_bar.sh's is_covered() hardcodes its jail flags and does NOT read jail_args, so it lacks the php seeds the features/lib suite needs. dot_resolver_install.sh still measures 39/39 under those flags, but the suite exits non-zero. This must be fixed before the gate is armed at allowlist-zero; it is out of scope here and recorded as the next blocker."
],
"rollback": [
"git revert the commit; the suite disappears and apply_fullscreen_confine_hook returns to aborting under set -e on a refactored upstream.",
"After rollback, confirm the warn branch is unreachable again by running the hook against a dwm.c lacking the setfullscreen shape -- it should abort rather than warn."
]
}

View File

@ -11,8 +11,8 @@
# only the two intentional behaviour changes below patch dwm.c.
# ---------------------------------------------------------------------------
install_config() {
log "Installing config.h from the repo (${REPO_DWM_DIR}/config.h)…"
cp -- "${REPO_DWM_DIR}/config.h" "$SRC_DIR/config.h"
log "Installing config.h from the repo (${REPO_DWM_DIR}/config.h)…"
cp -- "${REPO_DWM_DIR}/config.h" "$SRC_DIR/config.h"
}
# ---------------------------------------------------------------------------
@ -25,20 +25,20 @@ install_config() {
# and unused symbols are left alone), so our customisations always win.
# ---------------------------------------------------------------------------
heal_config() {
local defh="$SRC_DIR/config.def.h" cfgh="$SRC_DIR/config.h" dwmc="$SRC_DIR/dwm.c"
[[ -f "$defh" && -f "$dwmc" ]] || return 0
local line name added=0
while IFS= read -r line; do
name="$(sed -nE 's/^.*[^A-Za-z0-9_]([A-Za-z_][A-Za-z0-9_]*)[[:space:]]*=.*/\1/p' <<<"$line")"
[[ -n "$name" ]] || continue
grep -qw "$name" "$cfgh" && continue # we already define it — keep ours
grep -qw "$name" "$dwmc" || continue # dwm.c doesn't need it — skip
printf '%s\n' "$line" >>"$cfgh"
warn "config.h: auto-merged new upstream knob '$name' (bleeding-edge churn)"
added=1
done < <(grep -E '^[[:space:]]*static[[:space:]]+const[[:space:]]+[^={]*=[^;{]*;' "$defh")
((added)) && log "Merged upstream config symbol(s) into config.h for this build."
return 0
local defh="$SRC_DIR/config.def.h" cfgh="$SRC_DIR/config.h" dwmc="$SRC_DIR/dwm.c"
[[ -f "$defh" && -f "$dwmc" ]] || return 0
local line name added=0
while IFS= read -r line; do
name="$(sed -nE 's/^.*[^A-Za-z0-9_]([A-Za-z_][A-Za-z0-9_]*)[[:space:]]*=.*/\1/p' <<<"$line")"
[[ -n "$name" ]] || continue
grep -qw "$name" "$cfgh" && continue # we already define it — keep ours
grep -qw "$name" "$dwmc" || continue # dwm.c doesn't need it — skip
printf '%s\n' "$line" >>"$cfgh"
warn "config.h: auto-merged new upstream knob '$name' (bleeding-edge churn)"
added=1
done < <(grep -E '^[[:space:]]*static[[:space:]]+const[[:space:]]+[^={]*=[^;{]*;' "$defh")
((added)) && log "Merged upstream config symbol(s) into config.h for this build."
return 0
}
# ---------------------------------------------------------------------------
@ -57,25 +57,25 @@ heal_config() {
# rather than silently dropping the behaviour.
# ---------------------------------------------------------------------------
apply_focusonclick() {
local src="$SRC_DIR/dwm.c"
[[ -f "$src" ]] || return 0
local src="$SRC_DIR/dwm.c"
[[ -f "$src" ]] || return 0
perl -0777 -i -pe '
perl -0777 -i -pe '
s!\nenternotify\(XEvent \*e\)\n\{.*?\n\}\n!\nenternotify(XEvent *e)\n{\n\t/* focusonclick: pointer never changes focus; use a click or Mod+keys. */\n\t(void)e;\n}\n!s;
s!\nmotionnotify\(XEvent \*e\)\n\{.*?\n\}\n!\nmotionnotify(XEvent *e)\n{\n\t/* focusonclick: keep the active monitor fixed when crossing screens. */\n\t(void)e;\n}\n!s;
' "$src"
# Verify both rewrites landed; warn (never abort) if upstream changed shape.
local ok=1
grep -q 'focusonclick: pointer never changes focus' "$src" || ok=0
grep -q 'focusonclick: keep the active monitor fixed' "$src" || ok=0
if ((ok)); then
log "Applied focus-on-click (pointer no longer changes focus or switches monitors)."
else
warn "focus-on-click rewrite did NOT match upstream dwm.c — pointer focus unchanged."
warn "enternotify/motionnotify were likely refactored upstream; update dwm/patches."
fi
return 0
# Verify both rewrites landed; warn (never abort) if upstream changed shape.
local ok=1
grep -q 'focusonclick: pointer never changes focus' "$src" || ok=0
grep -q 'focusonclick: keep the active monitor fixed' "$src" || ok=0
if ((ok)); then
log "Applied focus-on-click (pointer no longer changes focus or switches monitors)."
else
warn "focus-on-click rewrite did NOT match upstream dwm.c — pointer focus unchanged."
warn "enternotify/motionnotify were likely refactored upstream; update dwm/patches."
fi
return 0
}
# ---------------------------------------------------------------------------
@ -91,37 +91,40 @@ apply_focusonclick() {
# dwm/patches/fullscreen-pointer-confine.patch file mirrors it for reading.
# ---------------------------------------------------------------------------
apply_fullscreen_confine_hook() {
local src="$SRC_DIR/dwm.c"
[[ -f "$src" ]] || return 0
local src="$SRC_DIR/dwm.c"
[[ -f "$src" ]] || return 0
perl -0777 -i -pe '
perl -0777 -i -pe '
s!(\n\t\tc->isfullscreen = 1;\n)!$1\t\tif (system("pconfine-auto on &")) {}\n!;
s!(\n\t\tc->isfullscreen = 0;\n)!$1\t\tif (system("pconfine-auto off &")) {}\n!;
s!(\nunmanage\(Client \*c, int destroyed\)\n\{\n\tMonitor \*m = c->mon;\n\tXWindowChanges wc;\n)!$1\tif (c->isfullscreen) { if (system("pconfine-auto off &")) {} }\n!;
' "$src"
# Expect: 1 "on", 2 "off" (setfullscreen-leave + unmanage). Warn if not.
local on off
on=$(grep -c 'pconfine-auto on' "$src")
off=$(grep -c 'pconfine-auto off' "$src")
if [[ "$on" == 1 && "$off" == 2 ]]; then
log "Applied auto pointer-confinement hook (locks the cursor to a fullscreen window's screen)."
else
warn "pointer-confine hook only partially applied (on=$on off=$off, expected 1/2)."
warn "setfullscreen/unmanage were likely refactored upstream; update dwm/patches."
fi
return 0
# Expect: 1 "on", 2 "off" (setfullscreen-leave + unmanage). Warn if not.
# `|| true`: grep -c exits 1 when the count is zero, and the caller runs
# under `set -e`. Without this the function aborts HERE on a refactored
# upstream -- i.e. exactly when the warning below is the thing we need.
local on off
on=$(grep -c 'pconfine-auto on' "$src" || true)
off=$(grep -c 'pconfine-auto off' "$src" || true)
if [[ "$on" == 1 && "$off" == 2 ]]; then
log "Applied auto pointer-confinement hook (locks the cursor to a fullscreen window's screen)."
else
warn "pointer-confine hook only partially applied (on=$on off=$off, expected 1/2)."
warn "setfullscreen/unmanage were likely refactored upstream; update dwm/patches."
fi
return 0
}
# ---------------------------------------------------------------------------
# 4. Build & install (PREFIX defaults to /usr/local).
# ---------------------------------------------------------------------------
build_install() {
log "Compiling dwm…"
make -C "$SRC_DIR" clean >/dev/null
make -C "$SRC_DIR" 2>&1 | tail -15
log "Installing dwm (sudo make install)…"
sudo make -C "$SRC_DIR" install 2>&1 | tail -8
log "Compiling dwm…"
make -C "$SRC_DIR" clean >/dev/null
make -C "$SRC_DIR" 2>&1 | tail -15
log "Installing dwm (sudo make install)…"
sudo make -C "$SRC_DIR" install 2>&1 | tail -8
}
# ---------------------------------------------------------------------------
@ -132,18 +135,18 @@ build_install() {
# (fullscreen just won't auto-lock the cursor).
# ---------------------------------------------------------------------------
build_pointer_confine() {
log "Compiling pointer-confine from the repo (${REPO_DWM_DIR}/pointer-confine.c)…"
local bin
bin="$(mktemp)"
if cc -std=c99 -pedantic -Wall -O2 "${REPO_DWM_DIR}/pointer-confine.c" -o "$bin" \
-lX11 -lXfixes -lXinerama 2>/tmp/pointer-confine-build.log; then
sudo install -m 755 "$bin" "$BIN_CONFINE"
log "Installed $BIN_CONFINE."
else
warn "pointer-confine failed to compile — fullscreen cursor-lock disabled (dwm itself is fine):"
sed 's/^/ /' /tmp/pointer-confine-build.log >&2 || true
fi
rm -f "$bin"
log "Compiling pointer-confine from the repo (${REPO_DWM_DIR}/pointer-confine.c)…"
local bin
bin="$(mktemp)"
if cc -std=c99 -pedantic -Wall -O2 "${REPO_DWM_DIR}/pointer-confine.c" -o "$bin" \
-lX11 -lXfixes -lXinerama 2>/tmp/pointer-confine-build.log; then
sudo install -m 755 "$bin" "$BIN_CONFINE"
log "Installed $BIN_CONFINE."
else
warn "pointer-confine failed to compile — fullscreen cursor-lock disabled (dwm itself is fine):"
sed 's/^/ /' /tmp/pointer-confine-build.log >&2 || true
fi
rm -f "$bin"
}
# ---------------------------------------------------------------------------
@ -152,15 +155,15 @@ build_pointer_confine() {
# them on PATH with the right mode.
# ---------------------------------------------------------------------------
write_session_files() {
log "Installing helper scripts from the repo and the lightdm xsession entry…"
sudo install -m 755 "${REPO_DWM_DIR}/bin/dwm-session" "$BIN_SESSION"
sudo install -m 755 "${REPO_DWM_DIR}/bin/dwmstatus" "$BIN_STATUS"
sudo install -m 755 "${REPO_DWM_DIR}/bin/dwm-rebuild" "$BIN_REBUILD"
sudo install -m 755 "${REPO_DWM_DIR}/bin/switch-wm" "$BIN_SWITCH"
sudo install -m 755 "${REPO_DWM_DIR}/bin/pconfine-auto" "$BIN_CONFINE_AUTO"
log "Installing helper scripts from the repo and the lightdm xsession entry…"
sudo install -m 755 "${REPO_DWM_DIR}/bin/dwm-session" "$BIN_SESSION"
sudo install -m 755 "${REPO_DWM_DIR}/bin/dwmstatus" "$BIN_STATUS"
sudo install -m 755 "${REPO_DWM_DIR}/bin/dwm-rebuild" "$BIN_REBUILD"
sudo install -m 755 "${REPO_DWM_DIR}/bin/switch-wm" "$BIN_SWITCH"
sudo install -m 755 "${REPO_DWM_DIR}/bin/pconfine-auto" "$BIN_CONFINE_AUTO"
# --- xsession entry for lightdm (absolute Exec path) --------------------
sudo tee "$XSESSION" >/dev/null <<'DESKTOP_EOF'
# --- xsession entry for lightdm (absolute Exec path) --------------------
sudo tee "$XSESSION" >/dev/null <<'DESKTOP_EOF'
[Desktop Entry]
Name=dwm (i3-like)
Comment=dynamic window manager, compiled from source
@ -175,16 +178,16 @@ DESKTOP_EOF
# 6. Verify the build links and the session is registered.
# ---------------------------------------------------------------------------
verify() {
log "Verifying install…"
local ver
ver="$(dwm -v 2>&1)" || true # dwm -v prints version then exit(1)
log "dwm version: ${ver:-<none>}"
command -v dwm >/dev/null && log "dwm binary: $(command -v dwm)"
[[ -f "$XSESSION" ]] && log "xsession registered: $XSESSION"
log "Verifying install…"
local ver
ver="$(dwm -v 2>&1)" || true # dwm -v prints version then exit(1)
log "dwm version: ${ver:-<none>}"
command -v dwm >/dev/null && log "dwm binary: $(command -v dwm)"
[[ -f "$XSESSION" ]] && log "xsession registered: $XSESSION"
}
print_summary() {
cat <<SUMMARY
cat <<SUMMARY
dwm is installed alongside i3 (i3 untouched).
This machine autologins (no session picker), so choose the WM you boot into:

View File

@ -0,0 +1,127 @@
#!/usr/bin/env bash
# Tests for aw_autostart.sh — ActivityWatch's autostart wiring and self-checks.
#
# The subject writes an XDG .desktop entry, appends an `exec` line to the i3
# config, and generates an i3blocks status script. All of it lands under
# $USER_HOME, which the suite points at a throwaway dir -- so unlike its
# siblings this one does not need root paths. It still runs under the jail
# with the rest of the directory's suites; see jail_args beside this file.
#
# The generated i3blocks script is asserted by EXECUTING it against stubbed
# pacman/pgrep, not by grepping its text: "AW on" vs "AW off" is the thing
# that reaches the status bar, and a heredoc that emits syntactically broken
# bash would pass a text check and fail in front of the user.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=./features_harness.sh
. "$SCRIPT_DIR/features_harness.sh"
_t_setup_env
trap _t_teardown EXIT
# The globals aw_autostart.sh inherits from setup_activitywatch.sh.
USER_HOME="$TEST_TMPDIR/home"
ACTUAL_USER="$(id -un)"
mkdir -p "$USER_HOME/.config/i3"
# test_setup calls these two; they live in the entry script, above the source
# line. Redefinable per-assertion, so each definition goes in a subshell -- a
# top-level redefinition would shadow the subject's own view for every later
# assertion.
check_activitywatch_installed() { return 1; }
check_activitywatch_running() { return 1; }
# shellcheck source=../aw_autostart.sh
. "$FEATURES_LIB_DIR/aw_autostart.sh"
# --- setup_autostart: no i3 config present ----------------------------------
rm -f "$USER_HOME/.config/i3/config"
no_i3_out="$(setup_autostart)"
desktop="$USER_HOME/.config/autostart/activitywatch.desktop"
_t_file_has "$desktop" 'Exec=aw-qt' "the XDG autostart entry execs aw-qt"
_t_file_has "$desktop" 'X-GNOME-Autostart-enabled=true' "the XDG entry enables GNOME autostart"
_t_has "$no_i3_out" 'i3 config not found' "setup_autostart reports a missing i3 config"
# --- setup_autostart: appends to an existing i3 config ----------------------
printf '# my i3 config\n' >"$USER_HOME/.config/i3/config"
added_out="$(setup_autostart)"
_t_file_has "$USER_HOME/.config/i3/config" 'exec --no-startup-id aw-qt' "setup_autostart appends the i3 exec line"
_t_has "$added_out" 'Added ActivityWatch to i3 config' "setup_autostart reports the i3 entry was added"
# --- setup_autostart: idempotent -- a second run must not duplicate ---------
again_out="$(setup_autostart)"
_t_eq "1" "$(grep -c 'exec --no-startup-id aw-qt' "$USER_HOME/.config/i3/config")" \
"a second run does not duplicate the i3 exec line"
_t_has "$again_out" 'already exists in i3 config' "setup_autostart reports the entry already exists"
# --- create_i3blocks_status -------------------------------------------------
status_out="$(create_i3blocks_status)"
status_script="$USER_HOME/.config/i3blocks/activitywatch_status.sh"
_t_eq "0" "$([[ -x $status_script ]] && echo 0 || echo 1)" "the i3blocks status script is executable"
_t_has "$status_out" 'interval=10' "the printed i3blocks block sets interval=10"
# --- the GENERATED script actually works ------------------------------------
# Not installed: pacman -Qi fails and aw-qt is absent from PATH.
# PATH is REPLACED, not prepended, for this one case: aw-qt is genuinely
# installed at /usr/bin/aw-qt on the dev host, so a prepended stub dir cannot
# hide it -- `command -v aw-qt` would find the real one and the case would
# silently assert nothing. The generated script needs only coreutils here.
_t_stub pgrep
printf '#!/usr/bin/env bash\nexit 1\n' >"$TEST_TMPDIR/bin/pacman"
chmod +x "$TEST_TMPDIR/bin/pacman"
uninstalled="$(PATH="$TEST_TMPDIR/bin:/usr/bin/coreutils-only" "$status_script")"
_t_has "$uninstalled" 'AW uninstalled' "the status script reports 'AW uninstalled' with no package and no binary"
# Installed via the aw-qt binary, but no process running: pgrep must FAIL.
printf '#!/usr/bin/env bash\nexit 0\n' >"$TEST_TMPDIR/bin/aw-qt"
chmod +x "$TEST_TMPDIR/bin/aw-qt"
printf '#!/usr/bin/env bash\nexit 1\n' >"$TEST_TMPDIR/bin/pgrep"
chmod +x "$TEST_TMPDIR/bin/pgrep"
off_out="$("$status_script")"
_t_has "$off_out" 'AW off' "the status script reports 'AW off' when installed but not running"
# Installed and running.
printf '#!/usr/bin/env bash\nexit 0\n' >"$TEST_TMPDIR/bin/pgrep"
chmod +x "$TEST_TMPDIR/bin/pgrep"
on_out="$("$status_script")"
_t_has "$on_out" 'AW on' "the status script reports 'AW on' when the process is found"
# Installed via the pacman package rather than the binary.
rm -f "$TEST_TMPDIR/bin/aw-qt"
printf '#!/usr/bin/env bash\nexit 0\n' >"$TEST_TMPDIR/bin/pacman"
chmod +x "$TEST_TMPDIR/bin/pacman"
pkg_out="$("$status_script")"
_t_has "$pkg_out" 'AW on' "the status script accepts the pacman package as proof of install"
# --- test_setup: everything present -----------------------------------------
present_out="$(
check_activitywatch_installed() { return 0; }
check_activitywatch_running() { return 0; }
test_setup
)"
_t_has "$present_out" '✓ ActivityWatch is installed' "test_setup reports an installed ActivityWatch"
_t_has "$present_out" '✓ ActivityWatch is running' "test_setup reports a running ActivityWatch"
_t_has "$present_out" '✓ XDG autostart file exists' "test_setup finds the XDG autostart file"
_t_has "$present_out" '✓ i3 autostart configured' "test_setup finds the i3 autostart line"
_t_has "$present_out" '✓ i3blocks status script created' "test_setup finds the i3blocks script"
# --- test_setup: nothing present --------------------------------------------
rm -f "$desktop" "$status_script" "$USER_HOME/.config/i3/config"
absent_out="$(
check_activitywatch_installed() { return 1; }
check_activitywatch_running() { return 1; }
test_setup
)"
_t_has "$absent_out" '✗ ActivityWatch is not installed' "test_setup reports a missing ActivityWatch"
_t_has "$absent_out" '✗ ActivityWatch is not running' "test_setup reports a stopped ActivityWatch"
_t_has "$absent_out" '✗ XDG autostart file missing' "test_setup reports the missing XDG file"
_t_has "$absent_out" '! i3 autostart may not be configured' "test_setup reports the missing i3 line"
_t_has "$absent_out" '✗ i3blocks status script missing' "test_setup reports the missing i3blocks script"
# --- show_instructions ------------------------------------------------------
instructions="$(show_instructions)"
_t_has "$instructions" 'http://localhost:5600' "show_instructions gives the web interface URL"
_t_has "$instructions" 'Super+Shift+R' "show_instructions gives the i3 reload shortcut"
_t_report "test_aw_autostart.sh"

View File

@ -0,0 +1,188 @@
#!/usr/bin/env bash
# Tests for dwm_config.sh — dwm's config install, healing and source patches.
#
# The subject is driven for real: it rewrites dwm.c with perl, appends to
# config.h, compiles with cc and installs to /usr/local/bin. The generated
# CONTENT is what is worth asserting -- a focus-on-click rewrite that silently
# stops matching upstream is precisely the bug a presence check would miss.
#
# Safe only under meta/scripts/shell_coverage_jail.sh: write_session_files and
# build_pointer_confine install into /usr/local/bin, which the jail
# bind-mounts to a throwaway dir. See jail_args beside this file.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=./features_harness.sh
. "$SCRIPT_DIR/features_harness.sh"
# --- Refuse to run outside the jail -----------------------------------------
# /usr/local/bin is bind-mounted to an empty dir inside the jail. Finding the
# host's own binaries there means we are NOT contained, and the installs below
# would overwrite the real ones.
if [[ -e /usr/local/bin/switch-wm ]] && [[ ! -w /usr/local/bin ]]; then
printf 'REFUSING: this suite must run under shell_coverage_jail.sh\n' >&2
exit 1
fi
_t_setup_env
trap _t_teardown EXIT
warn() { printf '[test-warn] %s\n' "$1" >&2; }
# The globals dwm_config.sh inherits from setup_dwm.sh above its source line.
SRC_DIR="$TEST_TMPDIR/src"
REPO_DWM_DIR="$TEST_TMPDIR/repo"
BIN_SESSION="/usr/local/bin/dwm-session"
BIN_STATUS="/usr/local/bin/dwmstatus"
BIN_REBUILD="/usr/local/bin/dwm-rebuild"
BIN_SWITCH="/usr/local/bin/switch-wm"
BIN_CONFINE="/usr/local/bin/pointer-confine"
BIN_CONFINE_AUTO="/usr/local/bin/pconfine-auto"
XSESSION="$TEST_TMPDIR/dwm.desktop"
mkdir -p "$SRC_DIR" "$REPO_DWM_DIR/bin"
# shellcheck source=../dwm_config.sh
. "$FEATURES_LIB_DIR/dwm_config.sh"
# --- install_config ---------------------------------------------------------
printf 'static const int ours = 1;\n' >"$REPO_DWM_DIR/config.h"
install_config
_t_file_has "$SRC_DIR/config.h" 'ours' "install_config copies the repo's config.h onto the clone"
# --- heal_config: no config.def.h is a clean no-op ---------------------------
heal_config
_t_eq "0" "$?" "heal_config returns 0 when config.def.h is absent"
# --- heal_config: merges a knob dwm.c needs and config.h lacks --------------
cat >"$SRC_DIR/config.def.h" <<'DEFH'
static const int refreshrate = 60;
static const int ours = 9;
static const int unused = 3;
DEFH
printf 'int main(void){return refreshrate + ours;}\n' >"$SRC_DIR/dwm.c"
heal_config
_t_file_has "$SRC_DIR/config.h" 'refreshrate' "heal_config merges an upstream knob dwm.c references"
_t_eq "1" "$(grep -c 'ours' "$SRC_DIR/config.h")" "heal_config keeps OUR value and does not duplicate it"
_t_eq "0" "$(grep -c 'unused' "$SRC_DIR/config.h")" "heal_config skips a knob dwm.c never references"
# --- apply_focusonclick: missing dwm.c is a clean no-op ---------------------
rm -f "$SRC_DIR/dwm.c"
apply_focusonclick
_t_eq "0" "$?" "apply_focusonclick returns 0 when dwm.c is absent"
# --- apply_focusonclick: rewrites both handlers ------------------------------
# Shaped like upstream: a column-0 closing brace ends each function body.
cat >"$SRC_DIR/dwm.c" <<'DWMC'
void
enternotify(XEvent *e)
{
Client *c;
if (c)
focus(c);
}
void
motionnotify(XEvent *e)
{
Monitor *m;
if (m)
selmon = m;
}
DWMC
apply_focusonclick
_t_file_has "$SRC_DIR/dwm.c" 'pointer never changes focus' "apply_focusonclick rewrites enternotify"
_t_file_has "$SRC_DIR/dwm.c" 'keep the active monitor fixed' "apply_focusonclick rewrites motionnotify"
_t_eq "0" "$(grep -c 'focus(c);' "$SRC_DIR/dwm.c")" "the original enternotify body is gone"
# --- apply_focusonclick: warns instead of aborting on refactored upstream ---
printf 'void\nsomething_else(void)\n{\n\treturn;\n}\n' >"$SRC_DIR/dwm.c"
focus_out="$(apply_focusonclick 2>&1)"
_t_has "$focus_out" 'did NOT match upstream' "apply_focusonclick warns when the rewrite does not match"
# --- apply_fullscreen_confine_hook: missing dwm.c is a clean no-op -----------
rm -f "$SRC_DIR/dwm.c"
apply_fullscreen_confine_hook
_t_eq "0" "$?" "apply_fullscreen_confine_hook returns 0 when dwm.c is absent"
# --- apply_fullscreen_confine_hook: 1 "on", 2 "off" --------------------------
cat >"$SRC_DIR/dwm.c" <<'DWMC'
void
setfullscreen(Client *c, int fullscreen)
{
if (fullscreen && !c->isfullscreen) {
c->isfullscreen = 1;
} else if (!fullscreen && c->isfullscreen) {
c->isfullscreen = 0;
}
}
void
unmanage(Client *c, int destroyed)
{
Monitor *m = c->mon;
XWindowChanges wc;
detach(c);
}
DWMC
hook_out="$(apply_fullscreen_confine_hook 2>&1)"
_t_eq "1" "$(grep -c 'pconfine-auto on' "$SRC_DIR/dwm.c")" "the hook adds exactly one 'on' call"
_t_eq "2" "$(grep -c 'pconfine-auto off' "$SRC_DIR/dwm.c")" "the hook adds two 'off' calls (leave + unmanage)"
_t_has "$hook_out" 'Applied auto pointer-confinement' "the hook reports success at 1/2"
# --- apply_fullscreen_confine_hook: warns on a partial match ----------------
printf 'void\nsetfullscreen(void)\n{\n\treturn;\n}\n' >"$SRC_DIR/dwm.c"
partial_out="$(apply_fullscreen_confine_hook 2>&1)"
_t_has "$partial_out" 'only partially applied' "the hook warns when setfullscreen was refactored"
# --- build_install ----------------------------------------------------------
_t_stub make
build_install
_t_called 'make' "build_install invokes make"
# --- build_pointer_confine: the compile succeeds ----------------------------
printf 'int main(void){return 0;}\n' >"$REPO_DWM_DIR/pointer-confine.c"
_t_stub cc
confine_out="$(build_pointer_confine 2>&1)"
_t_has "$confine_out" "Installed $BIN_CONFINE" "build_pointer_confine installs the helper on a clean compile"
_t_eq "0" "$([[ -f $BIN_CONFINE ]] && echo 0 || echo 1)" "the pointer-confine binary lands in /usr/local/bin"
# --- build_pointer_confine: a failed compile fails SOFT ---------------------
# The real cc fails on a C file that is not C; dwm itself must still install.
cat >"$TEST_TMPDIR/bin/cc" <<'FAILCC'
#!/usr/bin/env bash
# Mimic a real cc failure: dwm_config redirects our stderr to the build log,
# so writing there is enough -- no need to know which argv slot -o landed in.
printf 'error: broken\n' >&2
exit 1
FAILCC
chmod +x "$TEST_TMPDIR/bin/cc"
soft_out="$(build_pointer_confine 2>&1)"
_t_has "$soft_out" 'fullscreen cursor-lock disabled' "a failed compile warns instead of aborting"
# --- write_session_files ----------------------------------------------------
for helper in dwm-session dwmstatus dwm-rebuild switch-wm pconfine-auto; do
printf '#!/bin/sh\nexit 0\n' >"$REPO_DWM_DIR/bin/$helper"
done
write_session_files
_t_eq "0" "$([[ -x $BIN_SWITCH ]] && echo 0 || echo 1)" "write_session_files installs switch-wm executable"
_t_eq "0" "$([[ -x $BIN_CONFINE_AUTO ]] && echo 0 || echo 1)" "write_session_files installs pconfine-auto executable"
_t_file_has "$XSESSION" 'Exec=/usr/local/bin/dwm-session' "the xsession entry uses an absolute Exec path"
_t_file_has "$XSESSION" 'DesktopNames=dwm' "the xsession entry declares DesktopNames=dwm"
# --- verify -----------------------------------------------------------------
_t_stub dwm
verify_out="$(verify 2>&1)"
_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 ---------------------------------
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)"
# --- print_summary ----------------------------------------------------------
summary_out="$(print_summary)"
_t_has "$summary_out" 'switch-wm dwm' "print_summary documents the switch-wm command"
_t_has "$summary_out" 'Ctrl+Alt+F3' "print_summary documents the TTY recovery path"
_t_report "test_dwm_config.sh"