docs: add @teardown feature docs and checklist
This commit is contained in:
parent
e8bc4be382
commit
3d9cbfba1b
11
CLAUDE.md
11
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
|
- `$SHOUT_PROJECT_DIR` is set to `cwd` where `shout` was invoked
|
||||||
- stdout and stderr are merged (`exec 2>&1`)
|
- 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
|
## Style
|
||||||
|
|
||||||
- Strict TypeScript, Bun runtime
|
- Strict TypeScript, Bun runtime
|
||||||
|
|
|
||||||
19
README.md
19
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.
|
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...]
|
Usage: shout test [options] [files...]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,20 @@
|
||||||
<span class="output">OK</span></code></pre>
|
<span class="output">OK</span></code></pre>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h2>Setup & teardown</h2>
|
||||||
|
<p>Use <code class="bright">@setup</code> to share commands across test files. Use <code class="bright">@teardown</code> to clean up after tests — it runs regardless of pass/fail.</p>
|
||||||
|
<pre><code><span class="comment"># setup.shout</span>
|
||||||
|
<span class="output">export DB_URL=sqlite:data/test.db</span>
|
||||||
|
<span class="bright">@teardown</span> <span class="cmd">rm -f "$SHOUT_PROJECT_DIR/data/test.db"</span></code></pre>
|
||||||
|
<pre><code><span class="bright">@setup</span> <span class="cmd">setup.shout</span>
|
||||||
|
<span class="bright">@teardown</span> <span class="cmd">rm -f /tmp/extra-cleanup</span>
|
||||||
|
|
||||||
|
<span class="prompt">$</span> <span class="cmd">create-db && run-tests</span>
|
||||||
|
<span class="wildcard">...</span></code></pre>
|
||||||
|
<p><code>@teardown</code> can appear in both <code>.shout</code> files and setup files. Teardown failures produce warnings but don't affect test results.</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<h2>Run it</h2>
|
<h2>Run it</h2>
|
||||||
<pre><code><span class="prompt">$</span> <span class="cmd">shout test</span>
|
<pre><code><span class="prompt">$</span> <span class="cmd">shout test</span>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user