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
This commit is contained in:
Tam Nhu Tran
2026-04-16 00:20:01 -04:00
parent 2ba3a0ab02
commit 2e2ba1c09b
2 changed files with 4 additions and 4 deletions
@@ -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,
@@ -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,