Merge branch 'default-port-5400'
This commit is contained in:
commit
649796b078
|
|
@ -13,7 +13,7 @@ Transcript-based shell integration test runner. Bun + TypeScript.
|
||||||
- `--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`)
|
||||||
- `-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
|
- `--port-from <n>` — auto-assign `$PORT` starting from n (default `5400`)
|
||||||
- `--parallel` — run files in parallel
|
- `--parallel` — run files in parallel
|
||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ program
|
||||||
.option("--path <path>", "Prepend <path> to PATH (repeatable)", (val: string, acc: string[]) => [...acc, val], [])
|
.option("--path <path>", "Prepend <path> to PATH (repeatable)", (val: string, acc: string[]) => [...acc, val], [])
|
||||||
.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>")
|
.option("--port-from <n>", "Auto-assign $PORT starting from <n>", "5400")
|
||||||
.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)
|
||||||
|
|
@ -94,14 +94,14 @@ program
|
||||||
const start = performance.now()
|
const start = performance.now()
|
||||||
const results: TestResult[] = []
|
const results: TestResult[] = []
|
||||||
const cwd = process.cwd()
|
const cwd = process.cwd()
|
||||||
const portFrom = opts.portFrom ? parseInt(opts.portFrom, 10) : undefined
|
const portFrom = parseInt(opts.portFrom, 10)
|
||||||
if (portFrom !== undefined && Number.isNaN(portFrom)) {
|
if (Number.isNaN(portFrom)) {
|
||||||
console.error("--port-from must be an integer")
|
console.error("--port-from must be an integer")
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
let nextPort = portFrom
|
let nextPort = portFrom
|
||||||
|
|
||||||
const runOne = async (filePath: string, port: number | undefined) => {
|
const runOne = async (filePath: string, port: number) => {
|
||||||
const content = await readFile(filePath, "utf-8")
|
const content = await readFile(filePath, "utf-8")
|
||||||
const parsed = parse(relative(cwd, filePath), content)
|
const parsed = parse(relative(cwd, filePath), content)
|
||||||
|
|
||||||
|
|
@ -125,7 +125,7 @@ program
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Object.assign(envVars, setupEnvVars, userEnvVars)
|
Object.assign(envVars, setupEnvVars, userEnvVars)
|
||||||
if (port !== undefined && !("PORT" in userEnvVars) && !("PORT" in setupEnvVars)) {
|
if (!("PORT" in userEnvVars) && !("PORT" in setupEnvVars)) {
|
||||||
envVars["PORT"] = String(port)
|
envVars["PORT"] = String(port)
|
||||||
}
|
}
|
||||||
const merged: ShoutFile = { ...parsed, commands: [...setupCommands, ...parsed.commands] }
|
const merged: ShoutFile = { ...parsed, commands: [...setupCommands, ...parsed.commands] }
|
||||||
|
|
@ -205,7 +205,7 @@ program
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts.parallel) {
|
if (opts.parallel) {
|
||||||
const all = await Promise.all(files.map(f => runOne(f, nextPort !== undefined ? nextPort++ : undefined)))
|
const all = await Promise.all(files.map(f => runOne(f, nextPort++)))
|
||||||
for (const r of all) {
|
for (const r of all) {
|
||||||
printDots(r)
|
printDots(r)
|
||||||
results.push(r)
|
results.push(r)
|
||||||
|
|
@ -213,7 +213,7 @@ program
|
||||||
process.stdout.write("\n")
|
process.stdout.write("\n")
|
||||||
} else {
|
} else {
|
||||||
for (const filePath of files) {
|
for (const filePath of files) {
|
||||||
const r = await runOne(filePath, nextPort !== undefined ? nextPort++ : undefined)
|
const r = await runOne(filePath, nextPort++)
|
||||||
printDots(r)
|
printDots(r)
|
||||||
results.push(r)
|
results.push(r)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user