ShtukbaseStandard
archivo del paquete→ .shtukbase/packages/testing/checks/t03_run_record.ts

checks/t03_run_record.ts

30 líneas, 1.7 KB.

El archivo tal como está en el paquete: el código y sus comentarios no se traducen.

  1. // QTS-R03. A run is recorded in full: date, kind and commit; a run marked «not without regression» (passed: false)
  2. // says what fell (`regression`); when the number of checks is written, the counts (passed, partial, failed, not run)
  3. // add up to it.
  4. import type { Project, Result } from '../../collections/checks/lib/speclib.ts';
  5. import { main } from '../../collections/checks/lib/runner.ts';
  6. import { addr, has, missing, num } from '../../quality/checks/lib/qlib.ts';
  7. export const RULE = { id: 'qts-r03', title: 'A run is recorded in full', scope: 'all runs' };
  8. const COUNTS = ['nPassed', 'nPartial', 'nFailed', 'nNotRun'];
  9. export function check(p: Project, res: Result): void {
  10. if (!res.part('runs', p.need('QRUN'))) return;
  11. const recs = p.records('QRUN');
  12. res.scope = recs.map((r) => addr(r.id));
  13. for (const r of recs) {
  14. const a = addr(r.id), name = p.label(r, 'QRUN');
  15. const gap = missing(r, ['date', 'kind', 'commit']);
  16. 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');
  17. const passed = r.fm.passed;
  18. if ((passed === false || String(passed) === 'false') && !has(r, 'regression'))
  19. res.hole(a, `${name}: there is a regression, but what failed is not said`, 'write in regression what failed', 'no-regression-text');
  20. if (has(r, 'nChecks')) {
  21. const total = num(r.fm.nChecks) ?? -1;
  22. const sum = COUNTS.reduce((s, f) => s + (num(r.fm[f]) ?? 0), 0);
  23. 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');
  24. }
  25. }
  26. }
  27. if (import.meta.main) main({ RULE, check });