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
fix: ignore macOS xcrun toolchain cache in Vitest temp-leak accounting (#10128)
Adam Eivy4e34a7837094
diff --git a/scripts/vitestTempRootSetup.js b/scripts/vitestTempRootSetup.jsindex 946e6d9332..fd6eb96925 100644--- a/scripts/vitestTempRootSetup.js+++ b/scripts/vitestTempRootSetup.js@@ -13,6 +13,12 @@ export function setup() {}// Exclude it only inside our owned root; never sweep arbitrary host directories.const VITEST_INTERNAL_SCRATCH_DIR = /^[A-Za-z0-9_-]{21}$/;+// macOS `xcrun` (spawned by any descendant resolving an Apple toolchain) writes+// its lookup cache to $TMPDIR, which is our owned root. It is toolchain-owned+// output, not fixture data: match the exact cache name only, so a real leaked+// fixture is still reported.+const TOOLCHAIN_CACHE_PREFIXES = new Set(['xcrun_db']);+export function groupLeakPrefix(name) {return name.replace(/[0-9a-zA-Z]{6,}$/, '') || name;}@@ -48,6 +54,7 @@ export function teardown() {entries = entries.filter((name) => name !== OWNER_FILE).filter((name) => !VITEST_INTERNAL_SCRATCH_DIR.test(name))+ .filter((name) => !TOOLCHAIN_CACHE_PREFIXES.has(groupLeakPrefix(name))).filter((name) => !isEffectivelyEmpty(join(root, name)));const byPrefix = new Map();diff --git a/scripts/vitestTempRootSetup.test.js b/scripts/vitestTempRootSetup.test.jsnew file mode 100644index 0000000000..7b6e5a44b9--- /dev/null+++ b/scripts/vitestTempRootSetup.test.js@@ -0,0 +1,43 @@+import { mkdirSync, mkdtempSync, rmSync, writeFileSync, existsSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { afterEach, describe, expect, it, vi } from 'vitest';+import { teardown } from './vitestTempRootSetup.js';++describe('vitestTempRootSetup teardown', () => {+ const originalRoot = process.env.PORTOS_TEST_TEMP_ROOT;+ const originalExit = process.exitCode;+ afterEach(() => {+ process.env.PORTOS_TEST_TEMP_ROOT = originalRoot;+ if (originalRoot === undefined) delete process.env.PORTOS_TEST_TEMP_ROOT;+ process.exitCode = originalExit;+ vi.restoreAllMocks();+ });++ function runTeardown(populate) {+ const root = mkdtempSync(join(tmpdir(), 'pvt-teardown-test-'));+ populate(root);+ process.env.PORTOS_TEST_TEMP_ROOT = root;+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});+ process.exitCode = undefined;+ teardown();+ const result = { warnings: warn.mock.calls.map((c) => c[0]), exitCode: process.exitCode, removed: !existsSync(root) };+ rmSync(root, { recursive: true, force: true });+ return result;+ }++ it('ignores the macOS xcrun cache but still fails on a real leaked fixture', () => {+ const clean = runTeardown((root) => writeFileSync(join(root, 'xcrun_db'), 'cache'));+ expect(clean.warnings).toEqual([]);+ expect(clean.exitCode).toBeUndefined();+ expect(clean.removed).toBe(true);++ const leaked = runTeardown((root) => {+ writeFileSync(join(root, 'xcrun_db'), 'cache');+ mkdirSync(join(root, 'fixture-Abc123'));+ writeFileSync(join(root, 'fixture-Abc123', 'data.json'), '{}');+ });+ expect(leaked.warnings).toEqual(['⚠️ test temp leak: fixture- ×1']);+ expect(leaked.exitCode).toBe(1);+ });+});