Widens the identity ratchet in scripts/lint-regression-test-names.cjs from banning only new bug-NNNN-*.test.cjs files to also banning fix-NNNN-*.test.cjs and issue-NNNN-*.test.cjs, per epic #3053's own recorded decision: extend only after the 74-file fix-*/issue-* backlog fully drains, never before. That precondition is now real, not assumed: this branch is rebased onto origin/next with Waves 1-6 (#3341, #3342, #3373, #3376, #3378, #3383) all merged, and a repo-wide check confirms zero tests/fix-*.test.cjs or tests/issue-<N>-*.test.cjs files remain -- only the two known false matches (issue-dedupe.test.cjs, issue-version-gate.test.cjs, feature-named suites with no digits after the prefix) survive the glob, and the widened regex correctly excludes both. Allowlist snapshotted at zero (scripts/lint-regression-test-names.allowlist.json was already [] and stays [] -- confirmed via --update reporting "already in sync"). Updated docs/TESTING-SUITES.md's Regression tests section to name fix-/issue- alongside bug- as banned new-file prefixes. This is the last commit of H3 (#3315)'s 7-wave decomposition.
This commit is contained in:
@@ -33,7 +33,8 @@ The suite-suffix convention was chosen over a directory layout (`tests/security/
|
||||
|
||||
## Regression tests
|
||||
|
||||
**Do not create new top-level `tests/bug-NNNN-*.test.cjs` files.** Add the
|
||||
**Do not create new top-level `tests/bug-NNNN-*.test.cjs`,
|
||||
`tests/fix-NNNN-*.test.cjs`, or `tests/issue-NNNN-*.test.cjs` files.** Add the
|
||||
regression case to the owning module's main test file instead (e.g. a
|
||||
`describe('regressions')` block in `tests/<module>.test.cjs`).
|
||||
|
||||
@@ -42,14 +43,16 @@ count — is the unit of CI overhead, and it is worst on Windows lanes where
|
||||
every spawn is Defender-scanned. The 2026-06 CI audit found 244 one-off
|
||||
`bug-*` files (~38% of the suite). That population is grandfathered in
|
||||
`scripts/lint-regression-test-names.allowlist.json` and enforced by an
|
||||
identity ratchet (`npm run lint:regression-names`, part of `npm run lint:ci`):
|
||||
identity ratchet (`npm run lint:regression-names`, part of `npm run lint:ci`),
|
||||
which also bans `fix-*` and `issue-*` NNNN-prefixed files the same way:
|
||||
|
||||
- A **new** `bug-*` file fails CI — fold it into the owning module's file.
|
||||
- A **new** `bug-*`, `fix-*`, or `issue-*` NNNN-prefixed file fails CI — fold
|
||||
it into the owning module's file.
|
||||
- **Deleting/consolidating** a grandfathered file requires pruning its
|
||||
allowlist entry, so the baseline only ever shrinks.
|
||||
- **Inherited drift** (the failure names files your PR didn't add — e.g. the
|
||||
base branch merged `bug-*` files without feeding the allowlist, or you
|
||||
rebased and carried a pre-rebase allowlist): run
|
||||
base branch merged `bug-*`/`fix-*`/`issue-*` files without feeding the
|
||||
allowlist, or you rebased and carried a pre-rebase allowlist): run
|
||||
`node scripts/lint-regression-test-names.cjs --update` and commit the
|
||||
regenerated allowlist. Snapshot artifacts like this allowlist (and
|
||||
`docs/INVENTORY.md`) must be regenerated **after** rebasing, never carried
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* lint-regression-test-names.cjs — ban NEW top-level bug-NNNN test files.
|
||||
* lint-regression-test-names.cjs — ban NEW top-level bug-NNNN/fix-NNNN/issue-NNNN test files.
|
||||
*
|
||||
* ## Why
|
||||
*
|
||||
@@ -17,20 +17,22 @@
|
||||
* ## What this enforces
|
||||
*
|
||||
* Identity ratchet (scripts/lib/allowlist-ratchet.cjs) over basenames matching
|
||||
* /^bug-\d+.*\.test\.cjs$/ in tests/:
|
||||
* - A NEW bug-* file (not in the allowlist) fails: fold the regression into
|
||||
* the owning module's test file instead.
|
||||
* - A REMOVED bug-* file with a stale allowlist entry also fails: prune the
|
||||
* entry from scripts/lint-regression-test-names.allowlist.json so the
|
||||
* baseline only ever shrinks.
|
||||
* /^(?:bug|fix|issue)-\d+.*\.test\.cjs$/ in tests/:
|
||||
* - A NEW bug-*, fix-*, or issue-* file (not in the allowlist) fails: fold
|
||||
* the regression into the owning module's test file instead.
|
||||
* - A REMOVED bug-*, fix-*, or issue-* file with a stale allowlist entry
|
||||
* also fails: prune the entry from
|
||||
* scripts/lint-regression-test-names.allowlist.json so the baseline only
|
||||
* ever shrinks.
|
||||
*
|
||||
* ## --update (allowlist drift repair)
|
||||
*
|
||||
* `node scripts/lint-regression-test-names.cjs --update` regenerates the
|
||||
* allowlist from the files currently in tests/ and reports what changed.
|
||||
* Use it when the failure is INHERITED drift, not your own new file — e.g.
|
||||
* the base branch merged bug-* files without feeding the allowlist (the
|
||||
* #947/#948/#950 race after the ratchet landed), or after a rebase. The
|
||||
* the base branch merged bug-*, fix-*, or issue-* files without feeding the
|
||||
* allowlist (the #947/#948/#950 race after the ratchet landed), or after a
|
||||
* rebase. The
|
||||
* allowlist is a snapshot artifact: regenerate it AFTER rebasing, never
|
||||
* carry a pre-rebase copy through.
|
||||
*
|
||||
@@ -49,7 +51,7 @@ const ALLOWLIST_PATH =
|
||||
process.env.GSD_LINT_REGRESSION_ALLOWLIST ||
|
||||
path.join(__dirname, 'lint-regression-test-names.allowlist.json');
|
||||
|
||||
const BUG_FILE_RE = /^bug-\d+.*\.test\.cjs$/;
|
||||
const BUG_FILE_RE = /^(?:bug|fix|issue)-\d+.*\.test\.cjs$/;
|
||||
|
||||
function main() {
|
||||
const args = process.argv.slice(2);
|
||||
@@ -97,8 +99,8 @@ function main() {
|
||||
for (const msg of failures) console.error(msg);
|
||||
if (novel.length > 0) {
|
||||
console.error(
|
||||
'\nIf this PR added the file(s) above: new bug-NNNN test files are not ' +
|
||||
"accepted — add the regression case to the owning module's test file " +
|
||||
'\nIf this PR added the file(s) above: new bug-NNNN/fix-NNNN/issue-NNNN ' +
|
||||
"test files are not accepted — add the regression case to the owning module's test file " +
|
||||
"(e.g. a describe('regressions') block in tests/<module>.test.cjs) instead.\n" +
|
||||
'If the file(s) came from the base branch (inherited allowlist drift, ' +
|
||||
'e.g. after a rebase): run ' +
|
||||
@@ -110,7 +112,7 @@ function main() {
|
||||
}
|
||||
|
||||
console.log(
|
||||
`ok lint-regression-test-names: ${current.length} grandfathered bug-* file(s), no novel offenders`
|
||||
`ok lint-regression-test-names: ${current.length} grandfathered bug-*/fix-*/issue-* file(s), no novel offenders`
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user