From 9609a8d252573ee2ce750a48bb9aa2ca42d54f5e Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Fri, 12 Jun 2026 00:05:26 -0700 Subject: [PATCH] test: move #2084 exitCode-containment lifecycle tests to the serial quarantine (R3) --- test/pglite-engine-disconnect.serial.test.ts | 35 ++++++++++++++++++++ test/pglite-engine.test.ts | 35 -------------------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/test/pglite-engine-disconnect.serial.test.ts b/test/pglite-engine-disconnect.serial.test.ts index 3c2fd75c7..d4ec84e4c 100644 --- a/test/pglite-engine-disconnect.serial.test.ts +++ b/test/pglite-engine-disconnect.serial.test.ts @@ -219,3 +219,38 @@ describe('PGLiteEngine.disconnect() — v0.41.8.0 lifecycle invariants', () => { } }); }); + +// ───────────────────────────────────────────────────────────────── +// #2084 — preservingProcessExitCode behavioral containment +// ───────────────────────────────────────────────────────────────── +describe('PGLiteEngine: Emscripten process.exitCode containment (#2084)', () => { + test('connect() leaves process.exitCode pinned at 0, not the Emscripten 99', async () => { + const prev = process.exitCode; + const eng = new PGLiteEngine(); + try { + await eng.connect({ engine: 'pglite' }); + // Emscripten writes 99 during create; the wrapper pins explicit 0 when + // nothing was set before (undefined cannot be restored — the accessor + // falls back to the WASM status). + expect(Number(process.exitCode)).toBe(0); + } finally { + await eng.disconnect(); + process.exitCode = prev; + } + }, 60_000); + + test('a pre-call verdict survives the create-throw path (finally restores)', async () => { + const prev = process.exitCode; + const eng = new PGLiteEngine(); + try { + process.exitCode = 3; + // A dataDir under a regular FILE cannot be created — PGlite.create rejects. + await expect( + eng.connect({ engine: 'pglite', database_path: '/dev/null/nope/brain' }), + ).rejects.toThrow(); + expect(Number(process.exitCode)).toBe(3); + } finally { + process.exitCode = prev; + } + }, 60_000); +}); diff --git a/test/pglite-engine.test.ts b/test/pglite-engine.test.ts index ece4abd4c..9ba2732d3 100644 --- a/test/pglite-engine.test.ts +++ b/test/pglite-engine.test.ts @@ -1299,41 +1299,6 @@ describe('PGLiteEngine: getHealth graph metrics', () => { }); }); -// ───────────────────────────────────────────────────────────────── -// #2084 — preservingProcessExitCode behavioral containment -// ───────────────────────────────────────────────────────────────── -describe('PGLiteEngine: Emscripten process.exitCode containment (#2084)', () => { - test('connect() leaves process.exitCode pinned at 0, not the Emscripten 99', async () => { - const prev = process.exitCode; - const eng = new PGLiteEngine(); - try { - await eng.connect({ engine: 'pglite' }); - // Emscripten writes 99 during create; the wrapper pins explicit 0 when - // nothing was set before (undefined cannot be restored — the accessor - // falls back to the WASM status). - expect(Number(process.exitCode)).toBe(0); - } finally { - await eng.disconnect(); - process.exitCode = prev; - } - }, 60_000); - - test('a pre-call verdict survives the create-throw path (finally restores)', async () => { - const prev = process.exitCode; - const eng = new PGLiteEngine(); - try { - process.exitCode = 3; - // A dataDir under a regular FILE cannot be created — PGlite.create rejects. - await expect( - eng.connect({ engine: 'pglite', database_path: '/dev/null/nope/brain' }), - ).rejects.toThrow(); - expect(Number(process.exitCode)).toBe(3); - } finally { - process.exitCode = prev; - } - }, 60_000); -}); - // ───────────────────────────────────────────────────────────────── // v0.13.1 — PGLite.create() error-wrap (structural guard for #223) // ─────────────────────────────────────────────────────────────────