mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 01:44:13 +00:00
ci(client): fail the count ratchets on an entry above the tree
lint:size, lint:layers, lint:rtl (both baselines), lint:skips and lint:warnings only failed a count that passed its entry. A count that fell below its entry was logged and nothing more, so a file that shrank could grow back to its old entry unseen, and the entry of a deleted file stayed behind for the next file at that path. lint:format and lint:offline already fail on such a stale entry, and the docs said these counts may only shrink. Each of them now fails on an entry that lowerCounts would lower or drop, naming its count or saying the file is gone, and tells to run --update, which still only lowers. staleCounts and reportStale in lib/ratchet.mjs hold the shared part. Every baseline matches the tree today, so none needed lowering. The client CLAUDE.md says so, and that CI lints through lint:warnings rather than lint:check.
This commit is contained in:
@@ -94,6 +94,23 @@ describe('lint:size', () => {
|
||||
expect(tree.error.join('\n')).toMatch(/src\/grew\.ts: 1150 lines/);
|
||||
});
|
||||
|
||||
it('SIZE-011: fails an entry above the file it holds, or for a file that is gone, until --update', () => {
|
||||
expect(run({ 'src/big.ts': 1200 }, { 'src/big.ts': lines(1100) })).toBe(1);
|
||||
expect(tree.error.join('\n')).toMatch(
|
||||
/src\/big\.ts is held at 1200 in scripts\/size-baseline\.json, but there are 1100 now/
|
||||
);
|
||||
expect(tree.error.join('\n')).toMatch(/npm run lint:size -- --update/);
|
||||
tree.remove();
|
||||
// A deleted file would hand its allowance to the next file at its path.
|
||||
expect(run({ 'src/gone.ts': 1200 }, { 'src/a.ts': lines(1) })).toBe(1);
|
||||
expect(tree.error.join('\n')).toMatch(/src\/gone\.ts is held at 1200 .*but the file is gone/);
|
||||
tree.remove();
|
||||
// Back under the limit is stale too: the entry would let it grow past the limit again.
|
||||
expect(run({ 'src/big.ts': 1200 }, { 'src/big.ts': lines(900) })).toBe(1);
|
||||
tree.remove();
|
||||
expect(run({ 'src/big.ts': 1200, 'src/gone.ts': 1200 }, { 'src/big.ts': lines(1100) }, true)).toBe(0);
|
||||
});
|
||||
|
||||
it('SIZE-009: a broken baseline stops the check', () => {
|
||||
tree = ratchetTree({ [BASELINE]: '{', 'src/a.ts': lines(1), 'tests/a.ts': lines(1), 'e2e/a.ts': lines(1) });
|
||||
expect(() => check({ root: tree.root, baselinePath: tree.path(BASELINE), ...tree.out })).toThrow(RatchetError);
|
||||
|
||||
Reference in New Issue
Block a user