mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-26 06:37:33 +00:00
ci(server): fail lint:size and lint:boundaries on stale baseline entries
Both server ratchets only logged an entry the tree had moved past. A file that shrank could grow back to its old size entry unseen, a deleted file left its allowance to the next file at its path, and a boundary violation that was fixed stayed allowed until someone ran --update. The client ratchets now fail on such entries, so the server ones do the same. lint:size fails on an entry above its file's size or for a file that is gone, and lint:boundaries on an entry that no longer occurs; both tell to run --update, which still only lowers or drops. Both baselines match the tree today.
This commit is contained in:
@@ -170,7 +170,7 @@ describe('import-boundaries.mjs', () => {
|
||||
expect(out).toContain('FAIL dbImportsNest: db/orm.ts -> nest/database/request-context.ts');
|
||||
});
|
||||
|
||||
it('BOUND-008: a baselined violation passes; a gone one is reported and --update drops it without adding', () => {
|
||||
it('BOUND-008: a baselined violation passes; a gone one fails and --update drops it without adding', () => {
|
||||
const files = {
|
||||
'nest/b/b.helpers.ts': 'export const h = 1;\n',
|
||||
'nest/a/a.service.ts': "import { h } from '../b/b.helpers';\nexport const a = h;\n",
|
||||
@@ -182,7 +182,10 @@ describe('import-boundaries.mjs', () => {
|
||||
expect(check.status).toBe(1);
|
||||
expect(check.out).toContain('FAIL domainInternals: c -> b/b.helpers.ts');
|
||||
expect(check.out).not.toContain('FAIL domainInternals: a -> b/b.helpers.ts');
|
||||
expect(check.out).toContain('1 baseline entry no longer occurs');
|
||||
expect(check.out).toContain(
|
||||
'FAIL domainInternals: z -> b/gone.ts is in scripts/import-boundaries-baseline.json but no longer occurs.',
|
||||
);
|
||||
expect(check.out).toContain('npm run lint:boundaries -- --update');
|
||||
|
||||
expect(run(dir, '--update').status).toBe(1);
|
||||
const written: unknown = JSON.parse(
|
||||
@@ -191,6 +194,18 @@ describe('import-boundaries.mjs', () => {
|
||||
expect(written).toEqual({ ...EMPTY, domainInternals: ['a -> b/b.helpers.ts'] });
|
||||
});
|
||||
|
||||
it('BOUND-011: a stale entry alone fails, and passes once --update dropped it', () => {
|
||||
const files = { 'nest/a/a.service.ts': 'export const a = 1;\n' };
|
||||
const dir = serverRoot(files, { ...EMPTY, domainCycles: ['a -> b', 'b -> a'] });
|
||||
const check = run(dir);
|
||||
expect(check.status).toBe(1);
|
||||
expect(check.out).toContain(
|
||||
'FAIL domainCycles: a -> b is in scripts/import-boundaries-baseline.json but no longer occurs.',
|
||||
);
|
||||
expect(run(dir, '--update').status).toBe(0);
|
||||
expect(run(dir).status).toBe(0);
|
||||
});
|
||||
|
||||
it('BOUND-009: fails closed on a missing or malformed baseline, a missing src/ and an unresolvable import', () => {
|
||||
const file = { 'x/a.ts': 'export const a = 1;\n' };
|
||||
expect(run(serverRoot(file, null)).out).toContain('cannot be read');
|
||||
|
||||
Reference in New Issue
Block a user