From 7ef200a4969a31ae6976b87eb78494f7917b3200 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Fri, 15 May 2026 23:04:13 -0500 Subject: test(scripts): add bats harness for audit + install-ai edge cases Adds scripts/tests/audit.bats (6 tests) and scripts/tests/install-ai.bats (5 tests) covering the three destructive edge cases that the fold-epic test plan deferred yesterday: audit --apply --force clobbering a tracked dirty .ai/, audit's loop continuing past a missing-.ai/ project, and install-ai's interactive fzf-pick form. The first two go alongside happy-path sanity (clean sweep, drift detection, --apply convergence, dirty-skip); install-ai gets happy-path with explicit PROJECT, --track gitkeep stubs, refusal on existing .ai/, and notes.org placeholder substitution. Strategy: redirect HOME to a per-test mktemp dir, scaffold synthetic project trees under HOME/code/, and run the real scripts against them. The canonical source stays the real one (resolved relative to each script's own location), so tests exercise the production rsync paths without copying canonical content. Use PATH stubs for fzf and find to cover the interactive and race-condition edges. Makefile test: target extended with a bats stanza; description updated to "Run all test suites (pytest + ERT + bats)". make test now runs 352 green (296 pytest + 22 lint-org ERT + 23 todo-cleanup ERT + 6 audit bats + 5 install-ai bats), up from 341. --- Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 9b41bc3..34b6e56 100644 --- a/Makefile +++ b/Makefile @@ -416,10 +416,15 @@ install-ai: ## Bootstrap .ai/ in a fresh project ([PROJECT=] [TRACK=1 | GI catchup-machine: ## Pull rulesets, refresh install, sync .ai/ across projects, verify doctor @bash scripts/catchup-machine.sh -test: ## Run the .ai/scripts/ test suites (pytest + ERT) +test: ## Run all test suites (pytest + ERT + bats) @cd .ai/scripts/tests && python3 -m pytest @set -e; for f in .ai/scripts/tests/test-*.el; do \ [ -e "$$f" ] || continue; \ echo "ert: $$(basename "$$f")"; \ emacs --batch -q -L .ai/scripts -l ert -l "$$f" -f ert-run-tests-batch-and-exit; \ done + @set -e; for f in scripts/tests/*.bats; do \ + [ -e "$$f" ] || continue; \ + echo "bats: $$(basename "$$f")"; \ + bats "$$f"; \ + done -- cgit v1.2.3