From 2e2ba1c09b81b5e79b7ec65bbd0979d5ce1a1204 Mon Sep 17 00:00:00 2001 From: Tam Nhu Tran Date: Thu, 16 Apr 2026 00:20:01 -0400 Subject: [PATCH] test(ci): use runtime-relative isolated child scripts - derive repo imports from each test file via file URLs - avoid hardcoded paths in the repo - launch child scripts with the current runtime for consistent local and runner behavior --- tests/unit/cliproxy/session-tracker-target.test.ts | 4 ++-- tests/unit/commands/tokens-command-auth-rotation.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit/cliproxy/session-tracker-target.test.ts b/tests/unit/cliproxy/session-tracker-target.test.ts index be4257e1..762e1f04 100644 --- a/tests/unit/cliproxy/session-tracker-target.test.ts +++ b/tests/unit/cliproxy/session-tracker-target.test.ts @@ -55,7 +55,7 @@ function runSessionTrackerScenario( const scriptPath = path.join(tempHome, `session-target-child-${Date.now()}.mjs`); fs.writeFileSync(scriptPath, script, 'utf8'); - const result = spawnSync('/bin/bash', ['-lc', `bun ${JSON.stringify(scriptPath)}`], { + const result = spawnSync(process.execPath, [scriptPath], { cwd: REPO_ROOT, env: { ...process.env, @@ -69,7 +69,7 @@ function runSessionTrackerScenario( if (result.status !== 0) { throw new Error( `child session-tracker scenario failed: ${JSON.stringify({ - command: `bun ${scriptPath}`, + command: `${process.execPath} ${scriptPath}`, status: result.status, signal: result.signal, error: result.error?.message ?? null, diff --git a/tests/unit/commands/tokens-command-auth-rotation.test.ts b/tests/unit/commands/tokens-command-auth-rotation.test.ts index 1ef6c716..9692148a 100644 --- a/tests/unit/commands/tokens-command-auth-rotation.test.ts +++ b/tests/unit/commands/tokens-command-auth-rotation.test.ts @@ -45,7 +45,7 @@ function runTokensCommandInChild(tempHome: string, args: string[]) { const scriptPath = path.join(tempHome, `tokens-child-${Date.now()}.mjs`); fs.writeFileSync(scriptPath, script, 'utf8'); - const result = spawnSync('/bin/bash', ['-lc', `bun ${JSON.stringify(scriptPath)}`], { + const result = spawnSync(process.execPath, [scriptPath], { cwd: REPO_ROOT, env: { ...process.env, @@ -60,7 +60,7 @@ function runTokensCommandInChild(tempHome: string, args: string[]) { if (result.status !== 0) { throw new Error( `child tokens command failed: ${JSON.stringify({ - command: `bun ${scriptPath}`, + command: `${process.execPath} ${scriptPath}`, status: result.status, signal: result.signal, error: result.error?.message ?? null,