Rename --bin to --path, support repeatable
This commit is contained in:
parent
89ab1f7959
commit
ff088f1156
|
|
@ -56,7 +56,7 @@ Options:
|
||||||
-u, --update Rewrite expected output in-place with actual output
|
-u, --update Rewrite expected output in-place 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
|
||||||
--bin <path> Prepend <path> to PATH
|
--path <path> Prepend <path> 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
|
||||||
--parallel Run files in parallel
|
--parallel Run files in parallel
|
||||||
|
|
|
||||||
4
SPEC.md
4
SPEC.md
|
|
@ -61,7 +61,7 @@ The following environment variables are set for every command:
|
||||||
| Variable | Value |
|
| Variable | Value |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `HOME` | the temp directory |
|
| `HOME` | the temp directory |
|
||||||
| `PATH` | inherited from host (or prepended via `--bin`) |
|
| `PATH` | inherited from host (or prepended via `--path`) |
|
||||||
| `CUE_DIR` | the temp directory |
|
| `CUE_DIR` | the temp directory |
|
||||||
|
|
||||||
All other environment variables are inherited from the host unless explicitly
|
All other environment variables are inherited from the host unless explicitly
|
||||||
|
|
@ -99,7 +99,7 @@ and subdirectories. Each command in each shout file is run sequentially
|
||||||
| `--update` / `-u` | Rewrite expected output in-place with actual output |
|
| `--update` / `-u` | Rewrite expected output in-place with actual output |
|
||||||
| `--keep` / `-k` | Keep temp directories after run (printed to stderr) |
|
| `--keep` / `-k` | Keep temp directories after run (printed to stderr) |
|
||||||
| `--clean-env` | Start with empty environment (only `PATH` and `CUE_DIR` set) |
|
| `--clean-env` | Start with empty environment (only `PATH` and `CUE_DIR` set) |
|
||||||
| `--bin <path>` | Prepend `<path>` to `PATH` |
|
| `--path <path>` | Prepend `<path>` to `PATH` (repeatable) |
|
||||||
| `--timeout <dur>` | Per-command timeout, e.g. `500ms`, `10s`, `1m` (default: `10s`) |
|
| `--timeout <dur>` | Per-command timeout, e.g. `500ms`, `10s`, `1m` (default: `10s`) |
|
||||||
| `--verbose` / `-v` | Print each command as it runs |
|
| `--verbose` / `-v` | Print each command as it runs |
|
||||||
| `--parallel` | Run files in parallel (implies all files run regardless of failures) |
|
| `--parallel` | Run files in parallel (implies all files run regardless of failures) |
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ program
|
||||||
.option("-u, --update", "Rewrite expected output in-place with actual output")
|
.option("-u, --update", "Rewrite expected output in-place with actual output")
|
||||||
.option("-k, --keep", "Keep temp directories after run")
|
.option("-k, --keep", "Keep temp directories after run")
|
||||||
.option("--clean-env", "Start with empty environment")
|
.option("--clean-env", "Start with empty environment")
|
||||||
.option("--bin <path>", "Prepend <path> to PATH")
|
.option("--path <path>", "Prepend <path> to PATH (repeatable)", (val: string, acc: string[]) => [...acc, val], [] as string[])
|
||||||
.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("--parallel", "Run files in parallel")
|
.option("--parallel", "Run files in parallel")
|
||||||
|
|
@ -95,7 +95,7 @@ $ true
|
||||||
|
|
||||||
const fileResult = await runFile(parsed, {
|
const fileResult = await runFile(parsed, {
|
||||||
cleanEnv: opts.cleanEnv ?? false,
|
cleanEnv: opts.cleanEnv ?? false,
|
||||||
binPath: opts.bin,
|
pathDirs: opts.path.length > 0 ? opts.path : undefined,
|
||||||
timeout: timeoutMs,
|
timeout: timeoutMs,
|
||||||
verbose: opts.verbose ?? false,
|
verbose: opts.verbose ?? false,
|
||||||
onCommand: opts.verbose
|
onCommand: opts.verbose
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ export type FileResult = {
|
||||||
|
|
||||||
type RunOptions = {
|
type RunOptions = {
|
||||||
cleanEnv: boolean
|
cleanEnv: boolean
|
||||||
binPath?: string
|
pathDirs?: string[]
|
||||||
timeout: number
|
timeout: number
|
||||||
verbose: boolean
|
verbose: boolean
|
||||||
onCommand?: (cmd: Command) => void
|
onCommand?: (cmd: Command) => void
|
||||||
|
|
@ -128,8 +128,8 @@ export async function runFile(
|
||||||
env["HOME"] = tmpDir
|
env["HOME"] = tmpDir
|
||||||
env["CUE_DIR"] = tmpDir
|
env["CUE_DIR"] = tmpDir
|
||||||
|
|
||||||
if (options.binPath) {
|
if (options.pathDirs?.length) {
|
||||||
env["PATH"] = options.binPath + ":" + (env["PATH"] ?? "")
|
env["PATH"] = options.pathDirs.join(":") + ":" + (env["PATH"] ?? "")
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user