From b780b917e39aecd11ab34137ddb16c92f3f2c2ce Mon Sep 17 00:00:00 2001 From: Tamika Nomara Date: Thu, 16 Jul 2026 23:21:13 +0400 Subject: [PATCH] chore(test): discover Bats tests repo-wide, not just test/ Change the `npm test` script to find every `*.bats` file outside node_modules and hand them to Bats, instead of recursing only `test/`. This lets a script's tests sit next to the script they cover, while `test/` stays home to harness-level checks. Bats has no built-in path or directory exclusion (its `--filter` family matches test names, not files, and there is no `.batsignore`), so a `find ... -prune | xargs` pipeline shapes the file list. It also prunes any nested node_modules and still runs not-yet-committed tests. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01VxmMsZfzA4d37Uh1rTfEDG --- CONTRIBUTING.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 15ee71d..0653ed3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,7 +35,7 @@ One-time setup, from the repo root: Everyday use: - `npm run lint` runs every hook over the whole repo (`prek run --all-files`). -- `npm test` runs the shell tests (`bats --recursive test/`). +- `npm test` runs the shell tests (every `*.bats` file in the repo outside `node_modules`). - If installed, every commit runs the lint hooks (Prettier, ShellCheck, and file hygiene) on your staged files. CI runs the same lint hooks and the tests on every pull request. @@ -46,7 +46,7 @@ How Prettier treats your files: - PR and issue templates under `.github/` are unwrapped rather than wrapped, because GitHub renders every newline in a PR or issue body as a line break. - The static archives under `docs/plans/` and `docs/research/`, and the vendored assets under `han-reporting/skills/html-summary/assets/`, are left untouched (`.prettierignore`). -Shell scripts are linted with ShellCheck. Tests live in `test/` as `*.bats` files and run in CI rather than on commit; run them locally with `npm test`. +Shell scripts are linted with ShellCheck. A script's tests sit next to it as a `*.bats` file in the same directory (for example `scripts/detect-git-context.sh` is covered by `scripts/detect-git-context.bats`); harness-level checks that aren't tied to one script live in `test/`. `npm test` discovers every `*.bats` file in the repo outside `node_modules`. Tests run in CI rather than on commit; run them locally with `npm test`. ## Which plugin does the change belong in? diff --git a/package.json b/package.json index 0655379..eb4a2a7 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "description": "Dev tooling for the han plugin suite (lint, format, and shell tests).", "scripts": { "lint": "prek run --all-files", - "test": "bats --recursive test/" + "test": "find . -name node_modules -prune -o -name '*.bats' -print0 | xargs -0 bats" }, "devDependencies": { "@j178/prek": "^0.4.9",