mirror of
https://github.com/JackChen-me/open-multi-agent.git
synced 2026-10-19 01:29:57 -05:00
The eval CLI tests and the two example smoke scripts located tsx with a fixed number of `..` segments, assuming a hoisted install directly above the workspace. A git worktree has no local node_modules and resolves upwards to the main checkout, and a non-hoisted install keeps node_modules inside the workspace, so the path pointed at nothing: spawnSync failed to launch and 12 tests reported `status: null` instead of a CLI exit code. Resolve `tsx/cli` through Node's own module resolution behind a shared tests/helpers/tsx-cli.ts, and spawn it with process.execPath rather than executing the node_modules/.bin shim, which is a .cmd wrapper on Windows that spawnSync cannot launch without a shell. `.bin/tsx` already links to the same dist/cli.mjs, so the spawned command is unchanged. Contributors can now run the full core suite directly from a worktree without hand-linking tsx.
33 lines
983 B
JavaScript
33 lines
983 B
JavaScript
import { spawn } from 'node:child_process'
|
|
import { createRequire } from 'node:module'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { join } from 'node:path'
|
|
|
|
const root = fileURLToPath(new URL('..', import.meta.url))
|
|
// Resolved rather than joined onto `root`: a git worktree has no local
|
|
// `node_modules` and resolves upwards to the main checkout.
|
|
const tsx = createRequire(import.meta.url).resolve('tsx/cli')
|
|
const example = join(
|
|
root,
|
|
'packages',
|
|
'core',
|
|
'examples',
|
|
'patterns',
|
|
'eval-offline-regression.ts',
|
|
)
|
|
|
|
await new Promise((resolve, reject) => {
|
|
const child = spawn(process.execPath, [tsx, example], {
|
|
cwd: root,
|
|
stdio: 'inherit',
|
|
env: { ...process.env, NO_COLOR: '1' },
|
|
})
|
|
child.once('error', reject)
|
|
child.once('exit', (code, signal) => {
|
|
if (code === 0) resolve()
|
|
else reject(new Error(`eval example failed with code ${code ?? 'null'} signal ${signal ?? 'none'}`))
|
|
})
|
|
})
|
|
|
|
console.log('evaluation example smoke: 1 passed')
|