diff --git a/CLAUDE.md b/CLAUDE.md index 81216eb..22912ea 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -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 diff --git a/src/cli/index.ts b/src/cli/index.ts index 2c3a72a..63e4c63 100755 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -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 diff --git a/src/run.ts b/src/run.ts index 8df05a7..a66968d 100644 --- a/src/run.ts +++ b/src/run.ts @@ -21,6 +21,8 @@ type RunOptions = { cleanEnv: boolean pathDirs?: string[] envVars?: Record + 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) diff --git a/web/index.html b/web/index.html index 854a6a9..e42394b 100644 --- a/web/index.html +++ b/web/index.html @@ -237,8 +237,10 @@ Options:

Environment

Shout sets these variables before running your commands:

HOME       temp directory for this test file
-SHOUT_DIR    same temp directory
-PATH       prepended with --path dirs, if any
+SHOUT_DIR same temp directory +SHOUT_SOURCE_DIR directory containing the .shout file +SHOUT_PROJECT_DIR directory where shout was invoked +PATH prepended with --path dirs, if any

Each file runs in its own temp directory. --clean-env starts with an empty environment instead of inheriting yours.