Visual Studio Code, rebuilt in Rust
Rust
test(port): fail when the README coverage block drifts from the ledger (#111)
Artur Rokc99bd63ce2f2
diff --git a/port/tools/readme-coverage.test.ts b/port/tools/readme-coverage.test.tsindex 915bab1dafa..3cb6aa17b7a 100644--- a/port/tools/readme-coverage.test.ts+++ b/port/tools/readme-coverage.test.ts@@ -38,6 +38,23 @@ test('an open part is listed with its gap count', () => {expect(readme).toContain('`b` 1.');});+test('the README coverage block matches the ledger (fix: bun port/tools/readme-coverage.ts)', () => {+ const repo = join(import.meta.dir, '../..');+ const readme = readFileSync(join(repo, 'README.md'), 'utf8');+ const root = mkdtempSync(join(tmpdir(), 'readme-coverage-test-'));+ mkdirSync(join(root, 'upstream'));+ // CI checks out no upstream/, so the version comes from the README itself.+ writeFileSync(join(root, 'upstream/package.json'), JSON.stringify({ version: readme.match(/parts of VS Code (\S+) the port/)![1] }));+ for (const path of ['README.md', 'port/ledger.md', 'port/ledger', 'port/tools/readme-coverage.ts', 'port/tools/ledger.ts', 'port/tools/vscode-src.ts']) {+ cpSync(join(repo, path), join(root, path), { recursive: true });+ }+ const run = Bun.spawnSync(['bun', join(root, 'port/tools/readme-coverage.ts')], { env: { ...process.env, VSCODE_SRC: 'upstream' } });+ expect(run.exitCode).toBe(0);+ const generated = readFileSync(join(root, 'README.md'), 'utf8');+ rmSync(root, { recursive: true });+ expect(generated).toBe(readme);+});+test('open milestone work rows keep the total below 100%', () => {const readme = coverageBlock(['| a | port feature | M1 | verified | | check |'], ['| M23 Linux | a.rs:1 | done | [linux S] x | |', '| M23 Linux | b.rs:1 | open | [linux S] y | |', '| M24 Windows | c.rs:1 | in progress | [windows M] z | |']);expect(readme).toContain('**2 of 4 items done (50%).**');