Files
ycode/scripts/run-alignment-regression.mjs
T

38 lines
2.5 KiB
JavaScript

/** Offline alignment regression: never starts a model service or Claude CLI. */
import { build } from 'esbuild'
import { spawnSync } from 'node:child_process'
const tests = [
'model-selection-alignment-regression.ts', 'model-settings-alignment-regression.ts', 'session-factory-alignment-regression.ts',
'session-composer-alignment-regression.tsx', 'alignment-conversation-regression.tsx', 'question-answer-shell-regression.tsx',
'runtime-authorization-regression.ts', 'permission-intercept-regression.tsx'
]
for (const file of tests) {
const format = file.endsWith('.tsx') ? 'cjs' : 'esm'
const outfile = `.tmp/alignment-tests/${file.replace(/\.tsx?$/, format === 'cjs' ? '.cjs' : '.mjs')}`
await build({ entryPoints: [`scripts/${file}`], outfile, bundle: true, platform: 'node', format, external: ['esbuild'], jsx: 'automatic', loader: { '.css': 'empty' }, logLevel: 'warning' })
const result = spawnSync(process.execPath, [outfile], { stdio: 'inherit', timeout: 120000 })
if (result.error) throw result.error
if (result.status !== 0) process.exit(result.status ?? 1)
}
// Host/SDK-interface fixtures; these builders stub query and never launch the CLI.
for (const file of ['scripts/build-runtime-regressions.mjs', '.tmp/claude-approval-policy-regression.mjs', '.tmp/claude-grant-replay-regression.mjs']) {
const result = spawnSync(process.execPath, [file], { stdio: 'inherit', timeout: 120000 })
if (result.error) throw result.error
if (result.status !== 0) process.exit(result.status ?? 1)
}
// Optional DOM tests use separately installed jsdom, not Electron/CLI or an upstream model.
if (process.env.YCODE_TEST_DOM_MODULE) {
for (const file of ['task-popconfirm-regression', 'question-interaction-regression', 'question-identity-regression', 'completed-fold-nested-regression', 'completed-fold-native-identity-regression', 'permission-intercept-dom-regression']) {
const outfile = `.tmp/alignment-tests/${file}.cjs`
await build({ entryPoints: [`scripts/${file}.tsx`], outfile, bundle: true, platform: 'node', format: 'cjs', jsx: 'automatic', loader: { '.css': 'empty' }, logLevel: 'warning' })
const result = spawnSync(process.execPath, [outfile], { stdio: 'inherit', timeout: 120000 })
if (result.error) throw result.error
if (result.status !== 0) process.exit(result.status ?? 1)
}
const modeChip = spawnSync(process.execPath, ['scripts/test-mode-chip.mjs'], { stdio: 'inherit', timeout: 120000 })
if (modeChip.error) throw modeChip.error
if (modeChip.status !== 0) process.exit(modeChip.status ?? 1)
}