Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test(pathological): the Postgres lane guard counts pathologicalArms() as a gated arm
garrytan99b81f7f7952
diff --git a/scripts/check-postgres-lane-coverage.ts b/scripts/check-postgres-lane-coverage.tsindex 86dce68d32..b202107359 100644--- a/scripts/check-postgres-lane-coverage.ts+++ b/scripts/check-postgres-lane-coverage.ts@@ -7,7 +7,7 @@* the file. This guard fails on every test/ file outside test/e2e/ that has* such an arm and no Postgres lane:*- * - arm: a zero-argument `testBackends()` call, or a `process.env.DATABASE_URL`+ * - arm: a zero-argument `testBackends()` or `pathologicalArms()` call, or a `process.env.DATABASE_URL`* read (directly or through a variable that holds it) used as a condition,* a call or constructor argument, or a `database_url`/`databaseUrl`* property value. Code inside a `withEnv({ DATABASE_URL: ... })` callback@@ -105,6 +105,9 @@ function underOwnDatabaseUrl(node: ts.Node): boolean {return false;}+/** Zero-argument calls that return the test's engine arms: `testBackends()` and the pathological harness's `pathologicalArms()`. */+const ARM_CALLS = new Set(['testBackends', 'pathologicalArms']);+/** First line of a Postgres arm in `path`, or null. */export function postgresArm(path: string): { line: number; what: string } | null {const sf = ts.createSourceFile(path, readFileSync(path, 'utf8'), ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);@@ -113,9 +116,9 @@ export function postgresArm(path: string): { line: number; what: string } | nullconst found: Array<{ line: number; what: string }> = [];const reads: ts.Node[] = [];const visit = (node: ts.Node): void => {- if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === 'testBackends' && node.arguments.length === 0+ if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && ARM_CALLS.has(node.expression.text) && node.arguments.length === 0&& !underOwnDatabaseUrl(node)) {- found.push({ line: line(node), what: 'testBackends()' });+ found.push({ line: line(node), what: `${node.expression.text}()` });}if (isDatabaseUrlRead(node) && !underOwnDatabaseUrl(node)) reads.push(node);ts.forEachChild(node, visit);diff --git a/test/scripts/postgres-lane-coverage.test.ts b/test/scripts/postgres-lane-coverage.test.tsindex 466ba37bb3..2ebd501fda 100644--- a/test/scripts/postgres-lane-coverage.test.ts+++ b/test/scripts/postgres-lane-coverage.test.ts@@ -32,6 +32,7 @@ const PG_ENV = ' env:\n DATABASE_URL: postgres://gbrain_test:gbrdescribe('check-postgres-lane-coverage.ts', () => {test.each([['a testBackends() loop', "for (const backend of testBackends()) describe(backend, () => {});\n"],+ ['a pathologicalArms() loop', "for (const arm of pathologicalArms()) describe(arm.backend, () => {});\n"],['a skipIf on DATABASE_URL', "test.skipIf(!process.env.DATABASE_URL)('postgres arm', () => {});\n"],['a variable holding DATABASE_URL', "const url = process.env.DATABASE_URL;\ndescribe.skipIf(!url)('postgres arm', () => {});\n"],['an if-gated connection', "beforeAll(async () => { if (process.env.DATABASE_URL) await isolatedPersistencePostgres(process.env.DATABASE_URL); });\n"],