Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
test: exercise runner-close cleanup in lifecycle fixtures (#12143)
Adam Eivy4b00d54b7688
diff --git a/client/src/test/vitestTempRoot.test.js b/client/src/test/vitestTempRoot.test.jsindex d38445c61d..2cea63651d 100644--- a/client/src/test/vitestTempRoot.test.js+++ b/client/src/test/vitestTempRoot.test.js@@ -42,8 +42,8 @@ describe('real client runner temp lifecycle', () => {const root = process.env.PORTOS_TEST_TEMP_ROOT;await import(${JSON.stringify(new URL('../../vitest.config.js?reimport', import.meta.url).href)});if (process.env.PORTOS_TEST_TEMP_ROOT !== root) throw Error('reimport created another root');- const { teardown } = await import(${JSON.stringify(new URL('../../../scripts/vitestTempRootSetup.js', import.meta.url).href)});- teardown();`], { env, encoding: 'utf8', timeout: 20000 });+ const { cleanupRunTempRoot } = await import(${JSON.stringify(new URL('../../../scripts/vitestTempRootSetup.js', import.meta.url).href)});+ cleanupRunTempRoot();`], { env, encoding: 'utf8', timeout: 20000 });expect(result.error).toBeUndefined();expect(result.status, `${result.stdout}\n${result.stderr}`).toBe(0);expect(readdirSync(host)).toEqual([]);diff --git a/scripts/lib/vitestStaleRunRoots.js b/scripts/lib/vitestStaleRunRoots.jsindex 8153a31f05..77254398e0 100644--- a/scripts/lib/vitestStaleRunRoots.js+++ b/scripts/lib/vitestStaleRunRoots.js@@ -2,7 +2,7 @@* Owner-aware sweep of run-scoped temp roots (#9113, #9804).** Workspace configs and the CI launcher stamp `.owner.pid` in each root. A- * killed run never reaches `teardown()` in `runTempRoot.js`, so its root is+ * killed run never reaches its runner close hook, so its root is* left behind; the next config load calls `sweepStaleRunRoots()` to reclaim* it for the caller's exact prefix (default `pvt-`). A recorded owner that is provably gone frees the root immediately, an* owner that is alive keeps it however old it is (a >6h run must not be sweptdiff --git a/scripts/vitestCiPool.test.js b/scripts/vitestCiPool.test.jsindex cf35021365..1b59a90189 100644--- a/scripts/vitestCiPool.test.js+++ b/scripts/vitestCiPool.test.js@@ -96,7 +96,7 @@ it('runs parallel units before exclusive, nonduplicated captures and cutover prowriteFileSync(path, source);};put('vitest.setup.js', "if (process.env.NODE_ENV !== 'test') throw Error('unsafe worker env');");- put('test/runTempRoot.js', `export { setup, teardown } from ${JSON.stringify(new URL('../server/test/runTempRoot.js', import.meta.url).href)};`);+ put('test/runTempRoot.js', `export { setup } from ${JSON.stringify(new URL('../server/test/runTempRoot.js', import.meta.url).href)};`);const common = `import { test, expect } from 'vitest';import { appendFileSync, existsSync, openSync, closeSync, unlinkSync, writeFileSync } from 'node:fs';diff --git a/server/services/htmlComposition/testBrowserCleanup.test.js b/server/services/htmlComposition/testBrowserCleanup.test.jsindex ed0e8c661f..10a852caf8 100644--- a/server/services/htmlComposition/testBrowserCleanup.test.js+++ b/server/services/htmlComposition/testBrowserCleanup.test.js@@ -859,17 +859,19 @@ describe('fixture-owned CDP artifacts root', () => {['removes the owned root', true, [], undefined],['reports an unremoved root with its creating test (negative control)', false,['⚠️ test temp leak: portos-cdp-artifacts- ×1 (created by testBrowserCleanup.test.js)'], 1],- ])('global teardown %s', async (_name, passHandle, warnings, exitCode) => {+ ])('runner close cleanup %s', async (_name, passHandle, warnings, exitCode) => {const artifacts = _createTestArtifactsRoot({ parent: runRoot });writeFileSync(join(artifacts.path, 'trace.json'), '{}');await _cleanupTestBrowser({ proc: exited(), artifacts: passHandle ? artifacts : undefined, cleanup: () => {} });- const { teardown } = await import('../../../scripts/vitestTempRootSetup.js');+ const { setup } = await import('../../../scripts/vitestTempRootSetup.js');+ const onClose = vi.fn();+ setup({ vitest: { onClose } });const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});const originalExit = process.exitCode;let observed;try {process.exitCode = undefined;- teardown();+ onClose.mock.calls[0][0]();observed = process.exitCode;} finally { process.exitCode = originalExit; }expect(warn.mock.calls.map(([line]) => line)).toEqual(warnings);