Migrate from Bun/TypeScript to Rust

This commit is contained in:
Chris Wanstrath 2026-04-02 16:47:23 -07:00
parent 0c9d4a27ce
commit faa4a4ce9e

View File

@ -1,12 +1,12 @@
# shout # shout
Transcript-based shell integration test runner. Bun + TypeScript. Transcript-based shell integration test runner. Rust.
## Commands ## Commands
- `bun test` — run unit tests - `cargo test` — run tests (integration tests in `tests/shout.rs`)
- `bunx tsc --noEmit` — type check - `cargo build` — build the binary
- `bun run src/cli/index.ts test [files...]` — run shout CLI - `cargo run -- test [files...]` — run shout CLI
- `-u, --update` — rewrite `.shout` files with actual output - `-u, --update` — rewrite `.shout` files with actual output
- `-k, --keep` — keep temp directories after run - `-k, --keep` — keep temp directories after run
- `--clean-env` — start with empty environment - `--clean-env` — start with empty environment
@ -19,15 +19,13 @@ Transcript-based shell integration test runner. Bun + TypeScript.
## Architecture ## Architecture
- `src/parse.ts` — parses `.shout` files into `ShoutFile` (list of `Command`) - `src/main.rs` — CLI entry point, arg parsing, file discovery, `run_one` orchestration
- `src/run.ts` — executes commands via `Bun.spawn(["/bin/sh"], { detached: true })`, captures output with sentinels - `src/parse.rs` — parses `.shout` files into `ShoutFile` (list of `Command`), also `parse_setup`
- `src/match.ts` — wildcard-aware output matching and diff generation - `src/run.rs` — executes commands via `/bin/sh`, captures output with sentinels
- `src/format.ts` — evaluates pass/fail, formats failures and summary - `src/matching.rs` — wildcard-aware output matching and diff generation
- `src/update.ts` — rewrites `.shout` files with actual output (`--update` mode) - `src/format.rs` — evaluates pass/fail, formats failures and summary
- `src/utils.ts` — shared utilities (`trimTrailingEmpty`, `escapeRegex`) - `src/update.rs` — rewrites `.shout` files with actual output (`--update` mode)
- `src/duration.ts` — parses duration strings (`10s`, `500ms`, `1m`) - `src/duration.rs` — parses duration strings (`10s`, `500ms`, `1m`)
- `src/cli/index.ts` — CLI entry point via `commander`
- `src/index.ts` — barrel exports
- `web/index.html` — web documentation page - `web/index.html` — web documentation page
## .shout file format ## .shout file format
@ -63,17 +61,16 @@ Transcript-based shell integration test runner. Bun + TypeScript.
## New feature checklist ## New feature checklist
1. `src/parse.ts` — update types (`Directive`, `ShoutFile`, `Command`) and both parsers (`parse` + `parseSetup`) 1. `src/parse.rs` — update types (`Directive`, `ShoutFile`, `Command`) and both parsers (`parse` + `parse_setup`)
2. `src/parse.test.ts` — unit tests for parsing the new syntax in both `.shout` and setup file contexts 2. `src/main.rs` — wire up the parsed result in `run_one` (directive resolution, command merging, result handling)
3. `src/cli/index.ts` — wire up the parsed result in `runOne` (directive resolution, command merging, result handling) 3. `tests/*.shout` — integration test file exercising the feature end-to-end
4. `tests/*.shout` — integration test file exercising the feature end-to-end 4. `CLAUDE.md` — update `.shout file format` section
5. `CLAUDE.md` — update `.shout file format` section 5. `README.md` — update Directives section
6. `README.md` — update Directives section 6. `web/index.html` — add or update a section on the website
7. `web/index.html` — add or update a section on the website 7. Run `cargo test` to verify
8. Run `cargo test` to verify
## Style ## Style
- Strict TypeScript, Bun runtime - Rust 2024 edition
- No classes — plain functions and types - No OOP — plain functions and structs/enums
- Integration tests in `tests/shout.rs`, example `.shout` files in `tests/` - Integration tests in `tests/shout.rs`, example `.shout` files in `tests/`