From c2275c81e6c3967b0f35cea823ad2fd3d252c6ad Mon Sep 17 00:00:00 2001 From: Gergo Magyar Date: Sun, 21 Jun 2026 08:33:07 +0000 Subject: [PATCH] test(lbug): de-brittle the close/CHECKPOINT structural guard (#2264 review P2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit lbug-checkpoint.test.ts grepped the adapter SOURCE (comments included) for conn.close()/db.close()/.query('CHECKPOINT') literals, coupling a passing test to comment wording — a prior commit had to reword a comment just to keep it green. Strip comments from the read source before the structural assertions so they reflect code only; the invariant (exactly two CHECKPOINT sites; close calls only in safeClose) is preserved and no longer breaks on a comment edit. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01JBJomjoTdBV2eveDVq4JMm --- gitnexus/test/unit/lbug-checkpoint.test.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gitnexus/test/unit/lbug-checkpoint.test.ts b/gitnexus/test/unit/lbug-checkpoint.test.ts index 06f54a044..d4b7c36f2 100644 --- a/gitnexus/test/unit/lbug-checkpoint.test.ts +++ b/gitnexus/test/unit/lbug-checkpoint.test.ts @@ -23,10 +23,20 @@ import { flushWAL } from '../../src/core/lbug/lbug-adapter.js'; describe('flushWAL / safeClose — consolidation guard (#1376)', () => { let adapterSource: string; + // Strip comments before the structural assertions so they reflect CODE only. + // Otherwise a `conn.close()` / `db.close()` / `.query('CHECKPOINT')` token + // mentioned in a doc comment would falsely trip (or vacuously satisfy) a guard, + // coupling the test to comment wording — exactly the brittleness flagged in the + // #2264 review (a prior commit had to reword a comment just to keep this green). + const codeOnly = (src: string): string => + src.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/[^\n]*/g, ''); + beforeAll(async () => { - adapterSource = await fs.readFile( - path.join(__dirname, '..', '..', 'src', 'core', 'lbug', 'lbug-adapter.ts'), - 'utf-8', + adapterSource = codeOnly( + await fs.readFile( + path.join(__dirname, '..', '..', 'src', 'core', 'lbug', 'lbug-adapter.ts'), + 'utf-8', + ), ); });