diff --git a/tests/scripts/codex-hooks.test.js b/tests/scripts/codex-hooks.test.js index 353c64efe..928d2a121 100644 --- a/tests/scripts/codex-hooks.test.js +++ b/tests/scripts/codex-hooks.test.js @@ -56,13 +56,14 @@ function runBash( scriptPath, { args = [], env = {}, cwd = repoRoot, input = undefined, preservePath = true } = {}, ) { - const bash = resolveBashExecutable(); + const effectiveEnv = { + ...(preservePath ? process.env : {}), + ...env, + }; + const bash = resolveBashExecutable(effectiveEnv); return spawnSync(bash, [scriptPath, ...args], { cwd, - env: { - ...(preservePath ? process.env : {}), - ...env, - }, + env: effectiveEnv, encoding: 'utf8', input, stdio: ['pipe', 'pipe', 'pipe'], @@ -148,6 +149,16 @@ if ( passed++; else failed++; +if ( + test('shell test runner honors a per-invocation BASH_PATH override', () => { + const missingBash = path.join(os.tmpdir(), 'ecc-missing-bash-executable'); + const result = runBash(prePushHook, { env: { BASH_PATH: missingBash } }); + assert.strictEqual(result.error?.code, 'ENOENT'); + }) +) + passed++; +else failed++; + function runHermeticPrePush({ failScript = null, includeCorepack = true,