main
1// The coverage matrix is checked, not remembered: every op is an export of its module, every test anchor is text in its
2// file, reference-git evidence cites a file that runs real git, run evidence names a recorded run and check, and
3// COVERAGE.md is the matrix rendered. The types (test/behaviours/types.ts, types.typetest.ts) refuse the rest.
4import { test } from 'vitest';
5import assert from 'node:assert/strict';
6import { readFileSync, existsSync } from 'node:fs';
7import { join, dirname } from 'node:path';
8import { fileURLToPath } from 'node:url';
9import { BEHAVIOURS } from './matrix.ts';
10import { RUNS } from './runs.ts';
11import { AREAS, EVIDENCE_KINDS } from './types.ts';
12import { renderMd, evidenceOf } from '../../scripts/coverage-matrix.mjs';
14const ROOT = join(fileURLToPath(import.meta.url), '..', '..', '..');
15const read = p => readFileSync(join(ROOT, p), 'utf8');
16const escapeRe = s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
17// Test sources write an apostrophe inside a quoted name as \' : an anchor matches either spelling.
18const contains = (src, anchor) => src.includes(anchor) || src.includes(anchor.replace(/'/g, "\\'"));
20test('COVERAGE.md is `npm run coverage-matrix -- --md` of the matrix', () => {
21 assert.equal(read('COVERAGE.md'), renderMd(), 'COVERAGE.md is stale: run `npm run coverage-matrix -- --md`');
22});
24test('ids are unique, each id is `<area>.<slug>`, and every area has behaviours', () => {
25 const ids = BEHAVIOURS.map(b => b.id);
26 assert.deepEqual(ids.filter((id, i) => ids.indexOf(id) !== i), [], 'duplicate ids');
27 for (const b of BEHAVIOURS) {
28 assert.ok(AREAS.includes(b.area), `${b.id}: unknown area ${b.area}`);
29 assert.match(b.id, new RegExp(`^${escapeRe(b.area)}\\.[a-z0-9]+(-[a-z0-9]+)*$`), `${b.id}: id must be ${b.area}.<kebab-slug>`);
30 }
31 for (const a of AREAS) assert.ok(BEHAVIOURS.some(b => b.area === a), `area ${a} has no behaviours`);
32});
34test('the status rules hold at run time too: verified has evidence, unsupported names no op and says why', () => {
35 for (const b of BEHAVIOURS) {
36 if (b.status.tag === 'verified') assert.ok(b.status.evidence.length > 0, `${b.id}: verified with no evidence`);
37 if (b.status.tag === 'unsupported') {
38 assert.equal(b.ops.length, 0, `${b.id}: unsupported but names ops`);
39 assert.ok(b.status.why.trim().length > 0, `${b.id}: unsupported with no reason`);
40 } else assert.ok(b.ops.length > 0, `${b.id}: ${b.status.tag} names no ply op`);
41 for (const e of evidenceOf(b)) assert.ok(EVIDENCE_KINDS.includes(e.kind), `${b.id}: unknown evidence kind ${e.kind}`);
42 }
43});
45test('every ply op is an export of its src module (grep, not memory)', () => {
46 const bad = [];
47 for (const b of BEHAVIOURS) for (const o of b.ops) {
48 if (!existsSync(join(ROOT, o.module))) { bad.push(`${b.id}: ${o.module} does not exist`); continue; }
49 const re = new RegExp(`export\\s+(async\\s+)?(function\\*?|const|let|class)\\s+${escapeRe(o.symbol)}\\b`);
50 if (!re.test(read(o.module))) bad.push(`${b.id}: ${o.module} does not export ${o.symbol}`);
51 }
52 assert.deepEqual(bad, []);
53});
55test('every cited test exists and contains its anchor', () => {
56 const bad = [];
57 for (const b of BEHAVIOURS) {
58 const refs = [...b.tests, ...evidenceOf(b).filter(e => e.ref.tag === 'test').map(e => e.ref)];
59 for (const r of refs) {
60 if (!existsSync(join(ROOT, r.path))) { bad.push(`${b.id}: ${r.path} does not exist`); continue; }
61 if (!contains(read(r.path), r.anchor)) bad.push(`${b.id}: ${r.path} does not contain ${JSON.stringify(r.anchor)}`);
62 }
63 }
64 assert.deepEqual(bad, []);
65});
67// A file runs real git if it, or a test helper it imports directly (a module under test/, never src/), starts the git
68// http-backend server or spawns git.
69const RUNS_GIT = /\bstartGitServer\(|(spawnSync|execFileSync|spawn|execFile)\(\s*['"]git['"]/;
70const runsGit = path => {
71 const src = read(path);
72 if (RUNS_GIT.test(src)) return true;
73 const local = [...src.matchAll(/from\s+['"](\.{1,2}\/[^'"]+)['"]/g)].map(m => join(dirname(path), m[1]));
74 return local.filter(p => p.startsWith('test/')).some(p => {
75 const candidates = [p, p.replace(/\.js$/, '.ts')];
76 return candidates.some(c => existsSync(join(ROOT, c)) && RUNS_GIT.test(read(c)));
77 });
78};
80test('ply_vs_reference_git evidence cites a file that runs real git', () => {
81 const bad = [];
82 for (const b of BEHAVIOURS) for (const e of evidenceOf(b)) {
83 if (e.kind === 'ply_vs_reference_git' && !runsGit(e.ref.path)) bad.push(`${b.id}: ${e.ref.path} runs no git`);
84 }
85 assert.deepEqual(bad, []);
86});
88test('run evidence names a recorded run, a check that run recorded, and a kind the run can back', () => {
89 const bad = [];
90 for (const b of BEHAVIOURS) for (const e of evidenceOf(b)) {
91 if (e.ref.tag !== 'run') continue;
92 const run = RUNS[e.ref.run];
93 if (run === undefined) { bad.push(`${b.id}: no run ${e.ref.run}`); continue; }
94 if (!run.checks.includes(e.ref.check)) bad.push(`${b.id}: ${e.ref.run} recorded no check ${JSON.stringify(e.ref.check)}`);
95 if (!run.kinds.includes(e.kind)) bad.push(`${b.id}: ${e.ref.run} cannot back ${e.kind}`);
96 }
97 assert.deepEqual(bad, []);
98});
Diagnostics4 git calls · 317 ms
CallStatusSizeTime0317 ms
discover200152 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200145 B · hit3 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=145 git.response.cache=HIT git.response.duration_ms=3 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=145 git.pkt.payload.max=76 git.ls_refs.count=2 git.ls_refs.head=refs/heads/main
fetchblob:none · deepen 1020038 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=312 git.response.bytes=38434 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=19912563f540228593df0c489082e5e2508e21e4 git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=6 git.pkt.data=4 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=38434 git.pkt.payload.max=38339 git.sideband.band1.bytes=38338 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=63 git.pack.bytes=38338 git.pack.ofs_delta=0 git.pack.ref_delta=8 git.pack.chain.max=8 git.pack.trailer=0bc36ab7adf82d3109177f11f1ea93f1ce071f77 git.pack.full=55Open pack map
fetch2002.0 KiB312 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=2012 git.response.cache=MISS git.response.duration_ms=312 git.fetch.wants=3aaf40956371f5352fae56a60cc35e020990e49e git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=2012 git.pkt.payload.max=1991 git.sideband.band1.bytes=1990 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/ply.git
- Ref
- refs/heads/main
- Commit
- 19912563f540228593df0c489082e5e2508e21e4
- cf-ray
- a5e2ea7d9e134bc2
- Request
- 2cc3f6e8…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format