Merge branch 'user-dir-env'
This commit is contained in:
commit
36492fcc96
|
|
@ -45,6 +45,8 @@ Transcript-based shell integration test runner. Bun + TypeScript.
|
|||
- Setup command failures abort the test with an error
|
||||
- Each file runs in a fresh temp dir with a single `/bin/sh` session
|
||||
- `$HOME` and `$SHOUT_DIR` are set to the temp dir automatically
|
||||
- `$SHOUT_SOURCE_DIR` is set to the directory containing the `.shout` file
|
||||
- `$SHOUT_PROJECT_DIR` is set to `cwd` where `shout` was invoked
|
||||
- stdout and stderr are merged (`exec 2>&1`)
|
||||
|
||||
## Style
|
||||
|
|
|
|||
|
|
@ -134,6 +134,8 @@ program
|
|||
cleanEnv: opts.cleanEnv ?? false,
|
||||
pathDirs: opts.path,
|
||||
envVars,
|
||||
sourceDir: resolve(dirname(filePath)),
|
||||
projectDir: cwd,
|
||||
timeout: timeoutMs,
|
||||
verbose: opts.verbose ?? false,
|
||||
onCommand: opts.verbose
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ type RunOptions = {
|
|||
cleanEnv: boolean
|
||||
pathDirs?: string[]
|
||||
envVars?: Record<string, string>
|
||||
sourceDir?: string
|
||||
projectDir?: string
|
||||
timeout: number
|
||||
verbose: boolean
|
||||
onCommand?: (cmd: Command) => void
|
||||
|
|
@ -128,6 +130,12 @@ export async function runFile(
|
|||
|
||||
env["HOME"] = tmpDir
|
||||
env["SHOUT_DIR"] = tmpDir
|
||||
if (options.sourceDir) {
|
||||
env["SHOUT_SOURCE_DIR"] = options.sourceDir
|
||||
}
|
||||
if (options.projectDir) {
|
||||
env["SHOUT_PROJECT_DIR"] = options.projectDir
|
||||
}
|
||||
|
||||
if (options.envVars) {
|
||||
Object.assign(env, options.envVars)
|
||||
|
|
|
|||
|
|
@ -237,8 +237,10 @@ Options:
|
|||
<h2>Environment</h2>
|
||||
<p>Shout sets these variables before running your commands:</p>
|
||||
<pre><code><span class="bright">HOME</span> <span class="dim">→</span> <span class="output">temp directory for this test file</span>
|
||||
<span class="bright">SHOUT_DIR</span> <span class="dim">→</span> <span class="output">same temp directory</span>
|
||||
<span class="bright">PATH</span> <span class="dim">→</span> <span class="output">prepended with --path dirs, if any</span></code></pre>
|
||||
<span class="bright">SHOUT_DIR</span> <span class="dim">→</span> <span class="output">same temp directory</span>
|
||||
<span class="bright">SHOUT_SOURCE_DIR</span> <span class="dim">→</span> <span class="output">directory containing the .shout file</span>
|
||||
<span class="bright">SHOUT_PROJECT_DIR</span> <span class="dim">→</span> <span class="output">directory where shout was invoked</span>
|
||||
<span class="bright">PATH</span> <span class="dim">→</span> <span class="output">prepended with --path dirs, if any</span></code></pre>
|
||||
<p>Each file runs in its own temp directory. <code>--clean-env</code> starts with an empty environment instead of inheriting yours.</p>
|
||||
</section>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user