// 二七王前端单测总运行器:逐个 spawn test_*.js(各自独立进程/全局),汇总结果 // 用法:node client/tests/run.js const fs = require('fs'); const path = require('path'); const cp = require('child_process'); const dir = __dirname; const files = fs.readdirSync(dir).filter(f => /^test_.*\.js$/.test(f)).sort(); let allOk = true; for (const f of files) { console.log('\n===== ' + f + ' ====='); const r = cp.spawnSync(process.execPath, [path.join(dir, f)], { stdio: 'inherit' }); if (r.status !== 0) allOk = false; } console.log('\n' + (allOk ? '===== 全部单测通过 =====' : '===== 存在失败单测 =====')); process.exit(allOk ? 0 : 1);