diff --git a/CLAUDE.md b/CLAUDE.md index 97ecc96..91ea242 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -54,6 +54,17 @@ Transcript-based shell integration test runner. Bun + TypeScript. - `$SHOUT_PROJECT_DIR` is set to `cwd` where `shout` was invoked - stdout and stderr are merged (`exec 2>&1`) +## New feature checklist + +1. `src/parse.ts` — update types (`Directive`, `ShoutFile`, `Command`) and both parsers (`parse` + `parseSetup`) +2. `src/parse.test.ts` — unit tests for parsing the new syntax in both `.shout` and setup file contexts +3. `src/cli/index.ts` — wire up the parsed result in `runOne` (directive resolution, command merging, result handling) +4. `test/*.shout` — integration test file exercising the feature end-to-end +5. `CLAUDE.md` — update `.shout file format` section +6. `README.md` — update Directives section +7. `web/index.html` — add or update a section on the website +8. Run `bun test` and `bun run src/cli/index.ts test test/` to verify + ## Style - Strict TypeScript, Bun runtime diff --git a/README.md b/README.md index 32a8d6a..8ab164e 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,25 @@ Prepend commands (and `@env` directives) from another `.shout` file: Setup commands run first and their failures abort the test. Setup files cannot themselves contain `@setup` — no nesting. If both the setup file and the user file define the same `@env`, the user file wins. +### `@teardown` + +Run a cleanup command after all test commands, regardless of pass/fail: + +``` +@teardown rm -f "$SHOUT_PROJECT_DIR/data/test.db" + +$ create-db && run-tests +... +``` + +Teardown failures produce warnings but don't affect test results. You can also put `@teardown` in setup files: + +``` +# setup.shout +export DB_URL=sqlite:data/test.db +@teardown rm -f "$SHOUT_PROJECT_DIR/data/test.db" +``` + ``` Usage: shout test [options] [files...] diff --git a/web/index.html b/web/index.html index bceb555..31a9124 100644 --- a/web/index.html +++ b/web/index.html @@ -204,6 +204,20 @@ OK +
+

Setup & teardown

+

Use @setup to share commands across test files. Use @teardown to clean up after tests — it runs regardless of pass/fail.

+
# setup.shout
+export DB_URL=sqlite:data/test.db
+@teardown rm -f "$SHOUT_PROJECT_DIR/data/test.db"
+
@setup setup.shout
+@teardown rm -f /tmp/extra-cleanup
+
+$ create-db && run-tests
+...
+

@teardown can appear in both .shout files and setup files. Teardown failures produce warnings but don't affect test results.

+
+

Run it

$ shout test