Files
shoes/scripts/require-tests.test.mjs
cfal 38523d65ed Add performance reports, Linux coverage, and rule property tests (#228)
Add advisory selector/reload performance reports, optional Linux unit/process coverage with changed-line summaries, and bounded rule-parser property tests to make regressions and verification gaps easier to spot. Reports reject invalid measurements and account for timing noise without introducing hard performance gates; existing tests and production behavior remain unchanged.
2026-10-26 16:50:44 +08:00

24 lines
1006 B
JavaScript

import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { spawnSync } from 'node:child_process';
import test from 'node:test';
test('shell guard requires a successful command and nonzero executed tests', t => {
fs.mkdirSync('.workstream-evidence', { recursive: true });
const tmp = fs.mkdtempSync(path.resolve('.workstream-evidence/test-guard-'));
t.after(() => fs.rmSync(tmp, { recursive: true, force: true }));
for (const [summary, code, expected] of [
['test result: ok. 1 passed; 0 failed;', 0, 0],
['test result: ok. 0 passed; 0 failed;', 0, 1],
['compiled only', 0, 1],
['test result: ok. 1 passed; 0 failed;', 9, 9],
]) {
const result = spawnSync('bash', ['.github/require-tests.sh', process.execPath, '-e',
`console.log(${JSON.stringify(summary)}); process.exit(${code});`], {
env: { ...process.env, TMPDIR: tmp }, encoding: 'utf8',
});
assert.equal(result.status, expected, result.stderr);
}
});