23 lines
1.3 KiB
JavaScript
23 lines
1.3 KiB
JavaScript
import { execFileSync, spawnSync } from 'node:child_process';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
|
|
const runId = process.env.DADA_TDD_RUN_ID ?? `wp5-07-green-${new Date().toISOString().replace(/[^0-9]/g, '')}`;
|
|
const testId = 'TDD-WP5-07-PREVIEW-001-grant-lifecycle';
|
|
const runDirectory = path.resolve('artifacts', 'tdd', runId, 'cases', testId);
|
|
fs.mkdirSync(runDirectory, { recursive: true });
|
|
const command = ['exec', 'vitest', 'run', 'tests/api/wp5-07-preview-grants.test.ts'];
|
|
const executable = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm';
|
|
const result = spawnSync(executable, command, { encoding: 'utf8', shell: process.platform === 'win32' });
|
|
const status = result.status === 0 ? 'passed' : 'failed';
|
|
const evidence = {
|
|
schema_version: '1.0', task_id: 'TASK-WP5-07', test_id: testId, run_id: runId,
|
|
phase: 'green', status, command: 'pnpm exec vitest run tests/api/wp5-07-preview-grants.test.ts',
|
|
commit: execFileSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf8' }).trim(),
|
|
exit_code: result.status ?? 1,
|
|
redaction: 'stdout/stderr intentionally excluded',
|
|
};
|
|
fs.writeFileSync(path.join(runDirectory, 'evidence.json'), `${JSON.stringify(evidence, null, 2)}\n`);
|
|
console.log(JSON.stringify(evidence));
|
|
process.exitCode = status === 'passed' ? 0 : 1;
|