Add -t/--filter flag for file path filtering

This commit is contained in:
Chris Wanstrath 2026-03-15 16:14:47 -07:00
parent fc2f2ecc41
commit 24314c9c95
4 changed files with 15 additions and 6 deletions

View File

@ -12,6 +12,7 @@ Transcript-based shell integration test runner. Bun + TypeScript.
- `--clean-env` — start with empty environment - `--clean-env` — start with empty environment
- `--path <path>` — prepend to `$PATH` (repeatable) - `--path <path>` — prepend to `$PATH` (repeatable)
- `--timeout <dur>` — per-command timeout (default `10s`) - `--timeout <dur>` — per-command timeout (default `10s`)
- `-t, --filter <pattern>` — only run files whose path contains `<pattern>`
- `-v, --verbose` — print each command as it runs - `-v, --verbose` — print each command as it runs
- `--port-from <n>` — auto-assign `$PORT` starting from n (default `5400`) - `--port-from <n>` — auto-assign `$PORT` starting from n (default `5400`)
- `--parallel` — run files in parallel - `--parallel` — run files in parallel

View File

@ -113,6 +113,7 @@ Options:
--clean-env Start with empty environment --clean-env Start with empty environment
--path <path> Prepend <path> to PATH (repeatable) --path <path> Prepend <path> to PATH (repeatable)
--timeout <dur> Per-command timeout (default: "10s") --timeout <dur> Per-command timeout (default: "10s")
-t, --filter Only run files matching <pattern> (substring match)
-v, --verbose Print each command as it runs -v, --verbose Print each command as it runs
--port-from <n> Auto-assign $PORT starting from n (default: "5400") --port-from <n> Auto-assign $PORT starting from n (default: "5400")
--parallel Run files in parallel --parallel Run files in parallel

View File

@ -80,20 +80,26 @@ program
.option("--timeout <dur>", "Per-command timeout", "10s") .option("--timeout <dur>", "Per-command timeout", "10s")
.option("-v, --verbose", "Print each command as it runs") .option("-v, --verbose", "Print each command as it runs")
.option("--port-from <n>", "Auto-assign $PORT starting from <n>", "5400") .option("--port-from <n>", "Auto-assign $PORT starting from <n>", "5400")
.option("-t, --filter <pattern>", "Only run files matching <pattern> (substring match)")
.option("--parallel", "Run files in parallel") .option("--parallel", "Run files in parallel")
.action(async (fileArgs: string[], opts) => { .action(async (fileArgs: string[], opts) => {
const timeoutMs = parseDuration(opts.timeout) const timeoutMs = parseDuration(opts.timeout)
const paths = fileArgs.length > 0 ? fileArgs : ["."] const paths = fileArgs.length > 0 ? fileArgs : ["."]
const files = await findShoutFiles(paths) let files = await findShoutFiles(paths)
if (files.length === 0) {
console.error("No .shout files found")
process.exit(1)
}
const start = performance.now() const start = performance.now()
const results: TestResult[] = [] const results: TestResult[] = []
const cwd = process.cwd() const cwd = process.cwd()
if (opts.filter) {
const pattern = opts.filter
files = files.filter(f => relative(cwd, f).includes(pattern))
}
if (files.length === 0) {
console.error(opts.filter ? `No .shout files matching "${opts.filter}"` : "No .shout files found")
process.exit(1)
}
const portFrom = parseInt(opts.portFrom, 10) const portFrom = parseInt(opts.portFrom, 10)
if (Number.isNaN(portFrom)) { if (Number.isNaN(portFrom)) {
console.error("--port-from must be an integer") console.error("--port-from must be an integer")

View File

@ -248,6 +248,7 @@ Options:
--clean-env Start with empty environment --clean-env Start with empty environment
--path &lt;path&gt; Prepend &lt;path&gt; to PATH (repeatable) --path &lt;path&gt; Prepend &lt;path&gt; to PATH (repeatable)
--timeout &lt;dur&gt; Per-command timeout (default: "10s") --timeout &lt;dur&gt; Per-command timeout (default: "10s")
-t, --filter Only run files matching &lt;pattern&gt; (substring match)
-v, --verbose Print each command as it runs -v, --verbose Print each command as it runs
--port-from &lt;n&gt; Auto-assign $PORT starting from n (default: "5400") --port-from &lt;n&gt; Auto-assign $PORT starting from n (default: "5400")
--parallel Run files in parallel --parallel Run files in parallel