Skip to content

Commit 48d89e2

Browse files
fix: three test suites had been silently disabled (#9)
Answering "do we have unit and e2e tests" turned up that three of them had not run since the src/ reorganisation. All three fail the same way: a path moved, nothing referenced the new location, and no CI job executed the script, so the breakage was invisible. test:integration → src/sql-integration.test.ts (moved to scenarios/) test:perf → src/limiter.simulation.test.ts (moved to policies/) test:compat → dist/compat/opossum.cjs (moved to adapters/) The compat one is the worst. Fixing the generator was not enough: the shim is written into .opossum-compat/ and that directory is treated as a cache, so every run kept using a shim generated before the move. The suite reported 0 of 0 STALLED for every file, which means the README's headline "362 of 362" claim was unverifiable — and the harness said so out loud rather than passing vacuously, which is the only reason it was recoverable. A generated file must not be cached alongside downloaded ones; the shim is now rewritten every run. 362 of 362 again. Root cause is not the paths, it is that nothing ran them. Coverage, smoke and docs were all in CI and all survived the reorg; these three were not, and a suite that never executes cannot be distinguished from one that passes. All three now run in CI. Plus scripts/check-test-scripts.mjs: every src/… path named in a package.json script must exist. It runs first in `verify` so it fails in a second instead of after a full coverage pass, and it fails if it ever matches zero paths, so it cannot go inert the way the thing it guards did.
1 parent 283d5d6 commit 48d89e2

5 files changed

Lines changed: 84 additions & 12 deletions

File tree

.changeset/stale-test-paths.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
"resilix": patch
3+
---
4+
5+
Three test suites had been silently disabled since the `src/` reorganisation, and none of them
6+
ran in CI, so nothing reported it.
7+
8+
- `test:integration` pointed at `src/sql-integration.test.ts` (now `src/scenarios/`)
9+
- `test:perf` pointed at `src/limiter.simulation.test.ts` (now `src/policies/`)
10+
- `test:compat` generated its opossum shim once and cached it, so every harness kept requiring
11+
`dist/compat/opossum.cjs` after the shim moved to `dist/adapters/`. The whole suite reported
12+
**0 of 0 STALLED** — meaning the README's "362 of 362" claim was unverifiable for days. The
13+
shim is now rewritten on every run, since it is a *generated* file rather than a cached one.
14+
15+
All three now run in CI, and `pnpm test:paths` fails the build if any path named in a
16+
`package.json` script does not exist. `verify` runs it first, so it fails in a second rather than
17+
after a full coverage pass.

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,13 @@ jobs:
1919
- run: pnpm lint
2020
- run: pnpm typecheck
2121
- run: pnpm test:coverage
22+
23+
# These three ran nowhere for days after the src/ reorg moved their targets, so nothing
24+
# noticed that test:integration and test:perf pointed at deleted paths and that the
25+
# opossum harness required dist/compat/opossum.cjs. A suite that is never executed is
26+
# indistinguishable from a suite that passes.
27+
- run: pnpm test:paths
28+
- run: pnpm test:perf
29+
- run: pnpm test:compat
2230
- run: pnpm build
2331
- run: pnpm check:package

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,14 @@
9696
},
9797
"scripts": {
9898
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsup",
99-
"verify": "pnpm lint && pnpm typecheck && pnpm test:coverage && pnpm build && pnpm check:package && pnpm test:smoke && pnpm docs:check",
99+
"verify": "pnpm lint && pnpm test:paths && pnpm typecheck && pnpm test:coverage && pnpm build && pnpm check:package && pnpm test:smoke && pnpm docs:check",
100100
"docs:dev": "vitepress dev docs",
101101
"docs:build": "vitepress build docs",
102102
"docs:check": "vitepress build docs && node scripts/check-links.mjs",
103103
"docs:preview": "vitepress preview docs",
104104
"dev": "tsup --watch",
105105
"test": "vitest run",
106+
"test:paths": "node scripts/check-test-scripts.mjs",
106107
"test:watch": "vitest",
107108
"test:coverage": "vitest run --coverage",
108109
"typecheck": "tsc --noEmit",
@@ -112,10 +113,10 @@
112113
"prepublishOnly": "pnpm build && pnpm test",
113114
"release": "changeset publish",
114115
"ci:version": "changeset version && biome format --write package.json",
115-
"test:integration": "RESILIX_TEST_DATABASE_URL=${RESILIX_TEST_DATABASE_URL:-postgres://postgres:resilix@localhost:5459/resilix_test} vitest run src/sql-integration.test.ts",
116+
"test:integration": "RESILIX_TEST_DATABASE_URL=${RESILIX_TEST_DATABASE_URL:-postgres://postgres:resilix@localhost:5459/resilix_test} vitest run src/scenarios/sql-integration.test.ts",
116117
"test:compat": "node scripts/opossum-compat.mjs",
117118
"test:smoke": "pnpm build && node scripts/smoke.mjs && node scripts/smoke.cjs",
118-
"test:perf": "RESILIX_PERF=1 vitest run src/limiter.simulation.test.ts"
119+
"test:perf": "RESILIX_PERF=1 vitest run src/policies/limiter.simulation.test.ts"
119120
},
120121
"devDependencies": {
121122
"@arethetypeswrong/cli": "^0.18.5",

scripts/check-test-scripts.mjs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Every test path named in package.json scripts must exist.
2+
//
3+
// `test:integration` and `test:perf` both pointed at pre-reorg paths for days. Neither runs in
4+
// `verify` or in CI — they need a Postgres and an opt-in env var — so `vitest`'s "No test files
5+
// found" exit code was never observed by anyone. A moved file silently disabled two suites.
6+
//
7+
// Zero dependencies, like everything else here.
8+
import { existsSync, readFileSync } from "node:fs";
9+
10+
const { scripts } = JSON.parse(readFileSync("package.json", "utf8"));
11+
const problems = [];
12+
let checked = 0;
13+
14+
for (const [name, body] of Object.entries(scripts ?? {})) {
15+
// any src/… path with a file extension, wherever it appears in the command
16+
for (const [, path] of String(body).matchAll(/(src\/[\w./-]+\.[cm]?tsx?)/g)) {
17+
checked++;
18+
if (!existsSync(path)) problems.push(`${name}${path} (no such file)`);
19+
}
20+
}
21+
22+
if (checked === 0) {
23+
console.error("✗ no test paths matched — this checker has gone inert");
24+
process.exit(1);
25+
}
26+
if (problems.length) {
27+
console.error(`✗ ${problems.length} stale path(s) in package.json scripts:\n`);
28+
for (const p of problems) console.error(` ${p}`);
29+
process.exit(1);
30+
}
31+
console.log(`✓ ${checked} test paths in package.json scripts all exist`);

scripts/opossum-compat.mjs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,25 @@ const EXCLUDED = {
5454

5555
const RAW = (f) => `https://raw.githubusercontent.com/nodeshift/opossum/${REF}/test/${f}`;
5656

57+
/**
58+
* Point opossum's `require('../')` at our build.
59+
*
60+
* Rewritten on EVERY run, not just when the harness is first created. It used to be generated
61+
* once inside fetchSuite() and then cached alongside the downloaded suite — so when the shim
62+
* moved from dist/compat/ to dist/adapters/ during the src/ reorg, every cached harness kept
63+
* requiring a path that no longer existed. The whole suite reported 0 of 0 STALLED, which is a
64+
* generated file being treated as a downloaded one.
65+
*/
66+
const writeShim = () => {
67+
writeFileSync(
68+
join(HARNESS, "shim.cjs"),
69+
`const mod = require(${JSON.stringify(join(ROOT, "dist", "adapters", "opossum.cjs"))});
70+
module.exports = mod.default ?? mod;
71+
module.exports.default = module.exports;
72+
`,
73+
);
74+
};
75+
5776
const fetchSuite = async () => {
5877
mkdirSync(join(HARNESS, "test", "browser"), { recursive: true });
5978
for (const f of [...TESTS, "browser/browser-tap.js"]) {
@@ -65,14 +84,7 @@ const fetchSuite = async () => {
6584
join(HARNESS, "package.json"),
6685
`${JSON.stringify({ name: "opossum-compat-harness", private: true, main: "./shim.cjs" }, null, 2)}\n`,
6786
);
68-
// opossum's tests do `require('../')`; point that at our build.
69-
writeFileSync(
70-
join(HARNESS, "shim.cjs"),
71-
`const mod = require(${JSON.stringify(join(ROOT, "dist", "compat", "opossum.cjs"))});
72-
module.exports = mod.default ?? mod;
73-
module.exports.default = module.exports;
74-
`,
75-
);
87+
writeShim();
7688
execFileSync("npm", ["install", "--silent", "--no-audit", "--no-fund", "tape"], {
7789
cwd: HARNESS,
7890
stdio: "ignore",
@@ -103,8 +115,11 @@ const main = async () => {
103115
if (process.argv.includes("--refresh") || !existsSync(join(HARNESS, "shim.cjs"))) {
104116
console.log(`fetching opossum@${REF} test suite…`);
105117
await fetchSuite();
118+
} else {
119+
// The suite is cached; the shim is generated, so refresh it regardless. See writeShim().
120+
writeShim();
106121
}
107-
if (!existsSync(join(ROOT, "dist", "compat", "opossum.cjs"))) {
122+
if (!existsSync(join(ROOT, "dist", "adapters", "opossum.cjs"))) {
108123
console.log("building…");
109124
execFileSync("npm", ["run", "build"], { cwd: ROOT, stdio: "ignore" });
110125
}

0 commit comments

Comments
 (0)