mesh/merge-gate head 8635560993aa merged into trunk f9be71b9ad44 — pass: the change touches no module of the mesh's graph
mesh/repo-check head 8635560993aa merged into trunk f9be71b9ad44 — pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (typescript)…
mesh/delivery-group group fix/693-a-run-that-proved-nothing-is-not-passed ready: every member ready, and composed together they pass
mesh/delivery superseded: a newer head of the same pull request
The runner exits 0 when every test skipped, so a bed that stopped before its subject and skipped its only test as NOT REACHED was recorded as passed, "0 passed, 0 failed". The suite now collects each skip and its reason through a reporter of its own, prints NOT PASSED and a skipped line per skip after its recorded line, keeps them in the receipt, and exits 1 when no test passed or a test was not reached. A skip for a declared reason beside passes stays passed.
70 lines
3.2 KiB
TypeScript
70 lines
3.2 KiB
TypeScript
import { test } from "node:test";
|
||
import assert from "node:assert/strict";
|
||
import { counted, reportOn } from "../src/suite.ts";
|
||
|
||
// The totals come from the runner's own summary, and from nothing else.
|
||
test("the runner's totals are read from its summary", () => {
|
||
const said = counted("✔ something (1ms)\nℹ tests 22\nℹ pass 22\nℹ fail 0\n");
|
||
assert.deepEqual(said, { passed: 22, failed: 0, skipped: null });
|
||
});
|
||
|
||
// A test *named* like a total must not be mistaken for one. The summary is a line of its own, and
|
||
// the pattern says so — otherwise a test called "pass 3" would rewrite the record.
|
||
test("a test named like a total is not a total", () => {
|
||
const said = counted("✔ a machine reports pass 3 things (1ms)\nℹ pass 22\nℹ fail 0\n");
|
||
assert.equal(said.passed, 22, "a test name was read as the total");
|
||
});
|
||
|
||
// A failing run is read as a failing run.
|
||
test("failures are read", () => {
|
||
const said = counted("ℹ pass 21\nℹ fail 1\n");
|
||
assert.deepEqual(said, { passed: 21, failed: 1, skipped: null });
|
||
});
|
||
|
||
// **No totals is not zero failures.** A run whose result could not be read is a run nobody can say
|
||
// anything about, and writing "0 failed" because nothing said otherwise is how a green record
|
||
// comes to mean nothing — which is the whole of 04-ISSUES/005.
|
||
test("output with no summary yields no totals rather than a clean bill", () => {
|
||
const said = counted("the runner crashed before it said anything\n");
|
||
assert.equal(said.passed, null);
|
||
assert.equal(said.failed, null);
|
||
});
|
||
|
||
// No receipt rather than a guessed one.
|
||
//
|
||
// The rule that keeps the record meaning something, and it was first written where nothing could
|
||
// check it — 04-ISSUES/005 in miniature, inside the fix for it.
|
||
test("a run whose result could not be read writes nothing", () => {
|
||
let wrote = false;
|
||
const said = reportOn({ passed: null, failed: null }, [], () => {
|
||
wrote = true;
|
||
return { against: {}, ran: [] };
|
||
});
|
||
assert.equal(wrote, false, "a receipt was written for a run nobody could read");
|
||
assert.match(said, /no receipt written/);
|
||
});
|
||
|
||
test("a run that was read is recorded, with what it was read against", () => {
|
||
let got: [number, number] | null = null;
|
||
const said = reportOn({ passed: 22, failed: 0 }, [], (p, f) => {
|
||
got = [p, f];
|
||
return { against: { "mesh-lab": "abc1234" }, ran: ["test/integration/mesh.test.ts"] };
|
||
});
|
||
assert.deepEqual(got, [22, 0]);
|
||
assert.match(said, /mesh\.test\.ts — 22 passed, 0 failed, 0 skipped, against mesh-lab abc1234/);
|
||
assert.doesNotMatch(said, /NOT PASSED/);
|
||
});
|
||
|
||
// The runner's real output, colours and all.
|
||
//
|
||
// Captured from `node --test` writing into a pipe rather than written by hand: the first version of
|
||
// counted() passed every test and read nothing, because the fixtures were clean text and the runner
|
||
// emits escape codes. A fixture that agrees with the mistake proves the mistake.
|
||
test("the runner's totals are read from output as it actually arrives", () => {
|
||
const real = "\u001b[34m\u2139 suites 0\u001b[39m\n" +
|
||
"\u001b[34m\u2139 pass 22\u001b[39m\n" +
|
||
"\u001b[34m\u2139 fail 0\u001b[39m\n" +
|
||
"\u001b[34m\u2139 duration_ms 98.9\u001b[39m\n";
|
||
assert.deepEqual(counted(real), { passed: 22, failed: 0, skipped: null });
|
||
});
|