-
Notifications
You must be signed in to change notification settings - Fork 60
cross-runtime: run node:test files under bun test, matching the deno treatment #820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
4358a7a
61a3c87
1b5017b
50bdd37
10d6f70
8954631
c95ec26
07daa4e
d0ce522
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,9 +85,54 @@ for (const blk of BLOCKS) { | |
| console.log(expected + "\n"); | ||
| } | ||
| } | ||
| // The published figures are hand-copied into the homepage COMPAT array and the | ||
| // blog's compatibility sentence, and nothing else rechecks them — both drifted | ||
| // silently when a re-measurement moved bun's score. --check compares each | ||
| // surface's one-decimal denoExclusions rates against results.json; a missing | ||
| // file exits 2 (uncheckable), a mismatch exits 1 like table drift. | ||
| function checkHandCopies() { | ||
| const s = results.scores.denoExclusions; | ||
| const by = Object.fromEntries(s.runtimes.map((r) => [r.runtime, r])); | ||
| const rate = (rt) => (by[rt].pass / s.nodePass * 100).toFixed(1); | ||
| const surfaces = [ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The two surfaces listed here are the two that are currently correct. The two that actually drifted during this PR aren't covered: Technical details# The hand-copy gate covers 2 of 4 surfaces
## Affected sites
- `tests/cross-runtime/readme-table.mjs:97` — `surfaces` lists the homepage `COMPAT` array and the blog sentence only.
- `wiki/research/node-test-suite-leverage.md:161` — publishes `nub 98.5%, deno 74.2%, bun 70.1%` (`denoExclusions`), `98.2 / 71.7 / 71.8` (`bunUniverse`) and `97.4 / 68.1 / 65.6` (`fullCorpus`). Tracked and world-readable. Currently correct, ungated, and this PR had to hand-edit it after the re-measurement.
- `tests/cross-runtime/README.md:26` — `1 node, 1 nub, 4 bun, 2 deno and 0 node25` are `meta.retried.<rt>.flippedToPass`, hand-written prose. The same line's `99 files flipped to pass and none flipped to fail` is likewise hand-derived.
- `tests/cross-runtime/readme-table.mjs:88-92` — the explanatory comment states the same two-surface enumeration, so the code and the prose agree with each other but not with the repo.
## Required outcome
- Every surface carrying a figure derived from `results.json` is either asserted by `--check` or explicitly named as out of scope, so the next re-measurement has a complete checklist.
## Suggested approach (optional)
- `README.md:26`'s five counts are the cheapest to add: they are direct `meta.retried.<rt>.flippedToPass` reads, so one more `surfaces` entry pointing at `README` with a `/flipped (\d+) node, (\d+) nub/`-style pattern ends that flip-flop class.
- The wiki line spans three lenses rather than one, so it may be better served by dropping the per-runtime percentages and pointing at the README table — which is already generated — than by adding nine more assertions.
## Open questions for the human
- Is the wiki doc meant to carry standing figures at all, or is a pointer to the generated table the better long-term shape given it has now drifted twice? |
||
| { | ||
| file: path.join(HERE, "../../site/src/app/(home)/page.tsx"), | ||
| wants: [ | ||
| { re: /name: 'Nub', rate: ([\d.]+), tests: '([\d,]+) \/ ([\d,]+)'/, rt: "nub" }, | ||
| { re: /name: 'Deno [\d.]+', rate: ([\d.]+), tests: '([\d,]+) \/ ([\d,]+)'/, rt: "deno" }, | ||
| { re: /name: 'Bun [\d.]+', rate: ([\d.]+), tests: '([\d,]+) \/ ([\d,]+)'/, rt: "bun" }, | ||
| ], | ||
| }, | ||
| { | ||
| file: path.join(HERE, "../../site/content/blog/introducing-nub.mdx"), | ||
| wants: [ | ||
| { re: /clears ([\d.]+)% of what real Node passes/, rt: "nub" }, | ||
| { re: /([\d.]+)% for Deno/, rt: "deno" }, | ||
| { re: /([\d.]+)% for Bun/, rt: "bun" }, | ||
| ], | ||
| }, | ||
| ]; | ||
| let bad = false; | ||
| for (const { file, wants } of surfaces) { | ||
| let src; | ||
| try { src = fs.readFileSync(file, "utf8"); } catch (e) { console.error(`cannot read ${file}: ${e.message}`); process.exit(2); } | ||
| for (const { re, rt } of wants) { | ||
| const m = re.exec(src); | ||
| if (!m) { console.error(`${path.basename(file)}: pattern for ${rt} not found (${re})`); bad = true; continue; } | ||
| if (m[1] !== rate(rt)) { console.error(`${path.basename(file)}: ${rt} says ${m[1]}, results.json says ${rate(rt)}`); bad = true; } | ||
| if (m[2] && (m[2] !== n(by[rt].pass) || m[3] !== n(s.nodePass))) { | ||
| console.error(`${path.basename(file)}: ${rt} tests say ${m[2]} / ${m[3]}, results.json says ${n(by[rt].pass)} / ${n(s.nodePass)}`); | ||
| bad = true; | ||
| } | ||
| } | ||
| } | ||
| return bad; | ||
| } | ||
|
|
||
| if (process.argv.includes("--check")) { | ||
| if (checkHandCopies()) drifted = true; | ||
| if (drifted) process.exit(1); | ||
| console.log("README tables match results.json"); | ||
| console.log("README tables and site figures match results.json"); | ||
| } else if (process.argv.includes("--write")) { | ||
| fs.writeFileSync(README, readme); | ||
| console.log("README tables rewritten"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.githooks/pre-push:228decides whether to run--checkwithgit diff --name-only "$base" "$local_sha" -- tests/cross-runtime/, but the new assertions read files undersite/— which that trigger never examines. A push editing onlypage.tsxorintroducing-nub.mdxtherefore never runs them. The claim holds for the regenerate-results-first direction that drifted twice; it doesn't hold for a site-only edit.Technical details