package file→ .shtukbase/packages/testing/checks/t03_run_record.ts
checks/t03_run_record.ts
30 lines, 1.7 KB.
- // QTS-R03. A run is recorded in full: date, kind and commit; a run marked «not without regression» (passed: false)
- // says what fell (`regression`); when the number of checks is written, the counts (passed, partial, failed, not run)
- // add up to it.
- import type { Project, Result } from '../../collections/checks/lib/speclib.ts';
- import { main } from '../../collections/checks/lib/runner.ts';
- import { addr, has, missing, num } from '../../quality/checks/lib/qlib.ts';
- export const RULE = { id: 'qts-r03', title: 'A run is recorded in full', scope: 'all runs' };
- const COUNTS = ['nPassed', 'nPartial', 'nFailed', 'nNotRun'];
- export function check(p: Project, res: Result): void {
- if (!res.part('runs', p.need('QRUN'))) return;
- const recs = p.records('QRUN');
- res.scope = recs.map((r) => addr(r.id));
- for (const r of recs) {
- const a = addr(r.id), name = p.label(r, 'QRUN');
- const gap = missing(r, ['date', 'kind', 'commit']);
- if (gap.length) res.hole(a, `${name}: the run cannot be repeated — missing ${gap.join(', ')}`, 'add the date, the kind of run and the commit', 'not-recorded');
- const passed = r.fm.passed;
- if ((passed === false || String(passed) === 'false') && !has(r, 'regression'))
- res.hole(a, `${name}: there is a regression, but what failed is not said`, 'write in regression what failed', 'no-regression-text');
- if (has(r, 'nChecks')) {
- const total = num(r.fm.nChecks) ?? -1;
- const sum = COUNTS.reduce((s, f) => s + (num(r.fm[f]) ?? 0), 0);
- if (sum !== total) res.hole(a, `${name}: the count does not add up — ${r.fm.nChecks} checks, but the sum of the outcomes is ${sum}`, 'recount nPassed, nPartial, nFailed, nNotRun from the report', 'bad-count');
- }
- }
- }
- if (import.meta.main) main({ RULE, check });