包文件→ .shtukbase/packages/testing/checks/t02_test_path.ts
checks/t02_test_path.ts
22 行, 1.4 KB.
文件按包中的原样显示:代码及其注释不做翻译。
- // QTS-R02. A written test (pending or active: category working or done) can be found: it has a path (`test`) or a
- // reason why there is none (`testState`); an active automatic test (`how: auto`) always has a path.
- import type { Project, Result } from '../../collections/checks/lib/speclib.ts';
- import { main } from '../../collections/checks/lib/runner.ts';
- import { addr, has } from '../../quality/checks/lib/qlib.ts';
- 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"' };
- export function check(p: Project, res: Result): void {
- if (!res.part('quality tests', p.need('QTEST'))) return;
- const recs = p.records('QTEST').filter((t) => ['working', 'done'].includes(p.category(t, 'QTEST') ?? ''));
- res.scope = recs.map((t) => addr(t.id));
- for (const t of recs) {
- const name = p.label(t, 'QTEST');
- if (!has(t, 'test') && !has(t, 'testState'))
- 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');
- else if (!has(t, 'test') && String(t.fm.how ?? '') === 'auto' && p.category(t, 'QTEST') === 'done')
- 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');
- }
- }
- if (import.meta.main) main({ RULE, check });