21 lines
1005 B
JavaScript
21 lines
1005 B
JavaScript
/**
|
|||
|
|
* test/run.mjs — 저장소의 모든 테스트(test/*.test.mjs) 를 순서대로 별도 프로세스로 실행하고 요약한다.
|
||
|
|
* 외부 네트워크·실서버가 필요한 테스트는 ARIWEB_LIVE=1 일 때만 스스로 실행된다(각 파일이 판단).
|
||
|
|
*/
|
||
|
|
import { readdirSync } from 'node:fs';
|
||
|
|
import { spawnSync } from 'node:child_process';
|
||
|
|
import { fileURLToPath } from 'node:url';
|
||
|
|
import { dirname, join } from 'node:path';
|
||
|
|
|
||
|
|
const dir = dirname(fileURLToPath(import.meta.url));
|
||
|
|
const only = process.argv[2];
|
||
|
|
const files = readdirSync(dir).filter((f) => f.endsWith('.test.mjs') && (!only || f.includes(only))).sort();
|
||
|
|
let fail = 0;
|
||
|
|
for (const f of files) {
|
||
|
|
console.log(`\n▶ ${f}`);
|
||
|
|
const r = spawnSync(process.execPath, ['--no-warnings', join(dir, f)], { stdio: 'inherit', env: { ...process.env, NODE_ENV: 'test' } });
|
||
|
|
if (r.status !== 0) fail++;
|
||
|
|
}
|
||
|
|
console.log(`\n${fail ? '✘' : '✔'} 테스트 파일 ${files.length}개 중 실패 ${fail}개`);
|
||
|
|
process.exit(fail ? 1 : 0);
|