Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test(lanes): count pathologicalArms() as a Postgres arm in the lane guard (GBRA-130)

garrytan35c39eefa305
diff --git a/scripts/check-postgres-lane-coverage.ts b/scripts/check-postgres-lane-coverage.ts
index 86dce68d32..3cd4d5d077 100644
--- a/scripts/check-postgres-lane-coverage.ts
+++ b/scripts/check-postgres-lane-coverage.ts
@@ -7,7 +7,8 @@
* 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()` (the
+ * test/pathological/ harness wrapper) 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 +106,9 @@ function underOwnDatabaseUrl(node: ts.Node): boolean {
return false;
}
+/** Zero-argument calls that select the PostgreSQL arm when DATABASE_URL is set. */
+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 +117,9 @@ export function postgresArm(path: string): { line: number; what: string } | null
const 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.ts
index 466ba37bb3..0a1db35263 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:gbr
describe('check-postgres-lane-coverage.ts', () => {
test.each([
['a testBackends() loop', "for (const backend of testBackends()) describe(backend, () => {});\n"],
+ ['a pathologicalArms() loop (test/pathological/harness.ts)', "for (const { backend } of pathologicalArms()) describe(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"],