ShtukbaseStandard
файл пакета→ .shtukbase/packages/testing/checks/t02_test_path.ts

checks/t02_test_path.ts

22 строки, 1.4 КБ.

Файл как есть в пакете: код и комментарии в нём не переводятся.

  1. // QTS-R02. A written test (pending or active: category working or done) can be found: it has a path (`test`) or a
  2. // reason why there is none (`testState`); an active automatic test (`how: auto`) always has a path.
  3. import type { Project, Result } from '../../collections/checks/lib/speclib.ts';
  4. import { main } from '../../collections/checks/lib/runner.ts';
  5. import { addr, has } from '../../quality/checks/lib/qlib.ts';
  6. export const RULE = { id: 'qts-r02', title: 'A written test has a path or a reason why there is none', scope: 'quality tests in "Awaits the product" and "Active"' };
  7. export function check(p: Project, res: Result): void {
  8. if (!res.part('quality tests', p.need('QTEST'))) return;
  9. const recs = p.records('QTEST').filter((t) => ['working', 'done'].includes(p.category(t, 'QTEST') ?? ''));
  10. res.scope = recs.map((t) => addr(t.id));
  11. for (const t of recs) {
  12. const name = p.label(t, 'QTEST');
  13. if (!has(t, 'test') && !has(t, 'testState'))
  14. res.hole(addr(t.id), `${name}: the test cannot be found — no path and no reason`, 'write the path test (file::name) or the reason testState', 'no-test');
  15. else if (!has(t, 'test') && String(t.fm.how ?? '') === 'auto' && p.category(t, 'QTEST') === 'done')
  16. res.hole(addr(t.id), `${name}: an active autotest without a path`, 'write the path test (file::name) or return the test to "Awaits the product"', 'auto-no-path');
  17. }
  18. }
  19. if (import.meta.main) main({ RULE, check });