Files
orca/config/scripts/run-vitest.mjs
T
Jinwoo Hong 15d663fc3f Test runner uses the repo's pinned Bun, and refuses an older one instead of silently skipping tests (#31981)
* chore(test): run-vitest launches the pinned Bun, and refuses a Bun older than config/.bun-version

An older Bun silently runs no tests in files that reach newer node builtins, so a local
comparison could skip them on both sides.

Claude-Session: W5b

* chore(test): an older Bun ends run-vitest by exit code, so its message is not cut off

Claude-Session: W5b
2026-10-22 07:17:35 -04:00

42 lines
1.2 KiB
JavaScript

import { resolve } from 'node:path'
import { runProcessSync } from '@orca/process-host'
import {
checkBunVersion,
probeBunVersion,
readPinnedBunVersion,
resolvePinnedBunExecutable
} from './pinned-bun-executable.mjs'
const root = resolve(import.meta.dirname, '../..')
const pinnedBun = resolvePinnedBunExecutable(root, runProcessSync)
const bunCheck = pinnedBun
? { ok: true }
: checkBunVersion(probeBunVersion('bun', root, runProcessSync), readPinnedBunVersion(root))
if (bunCheck.message) {
console.error(bunCheck.message)
}
if (!bunCheck.ok) {
process.exitCode = 1
} else {
try {
const result = runProcessSync({
program: pinnedBun ?? 'bun',
args: ['--bun', resolve(root, 'node_modules/vitest/vitest.mjs'), ...process.argv.slice(2)],
cwd: root,
env: {
...process.env,
ORCA_BACKGROUND_LAUNCH: '1',
ORCA_TEST_NODE_EXECUTABLE: process.execPath,
ORCA_TEST_NODE_VERSION: process.versions.node
},
stdio: 'inherit',
timeoutMs: null
})
process.exitCode = result.code ?? 1
} catch (error) {
console.error('Could not start Vitest. Install the Bun version in config/.bun-version.', error)
process.exitCode = 1
}
}