Skip to content

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

address review (codex): make test:fast Windows-safe and wipe the git template

[._.]/ Adam Eivyc6079b0b33d0
diff --git a/server/lib/gitTestRepo.js b/server/lib/gitTestRepo.js
index 62b5ed0b23..b03314906e 100644
--- a/server/lib/gitTestRepo.js
+++ b/server/lib/gitTestRepo.js
@@ -11,13 +11,14 @@
* Pure-logic tests should not call these helpers at all.
*/
import { mkdtemp, rm, writeFile, cp, mkdir, readdir } from 'fs/promises';
+import { rmSync } from 'fs';
import { tmpdir } from 'os';
import { join } from 'path';
import { execGit } from './execGit.js';
export const SKIP_HEAVY_INTEGRATION = ['1', 'true', 'yes'].includes(
String(process.env.VITEST_FAST || '').toLowerCase(),
-);
+) || process.env.npm_lifecycle_event === 'test:fast';
const TEMPLATE_PREFIX = 'portos-git-template-';
const DEFAULT_IDENTITY = Object.freeze({
@@ -48,6 +49,11 @@ async function stripOrigin(repo) {
await execGit(['branch', '--unset-upstream'], repo, { ignoreExitCode: true });
}
+function wipeSync(scratch) {
+ if (!scratch) return;
+ try { rmSync(scratch, { recursive: true, force: true }); } catch { /* already gone */ }
+}
+
async function buildTemplate() {
const scratch = await mkdtemp(join(tmpdir(), TEMPLATE_PREFIX));
const repo = join(scratch, 'primary');
@@ -60,6 +66,10 @@ async function buildTemplate() {
await execGit(['init', '--bare', '-b', 'main', origin], scratch);
await execGit(['remote', 'add', 'origin', origin], repo);
await execGit(['push', '-u', 'origin', 'main'], repo);
+ // Copied sandboxes are torn down per-test; the template itself lives for
+ // the worker. Wipe it on process exit so watch-mode / repeated runs do
+ // not accumulate repos under os.tmpdir().
+ process.on('exit', () => wipeSync(scratch));
return { scratch, repo, origin };
}
diff --git a/server/package.json b/server/package.json
index ccddb675fc..cd71961321 100644
--- a/server/package.json
+++ b/server/package.json
@@ -10,7 +10,7 @@
"dev": "node --watch index.js",
"start": "node index.js",
"test": "vitest run",
- "test:fast": "VITEST_FAST=1 vitest run",
+ "test:fast": "vitest run",
"test:watch": "vitest",
"test:ci": "vitest run --bail=1 --silent=passed-only --reporter=default --reporter=github-actions",
"test:coverage": "vitest run --coverage",
diff --git a/server/vitest.config.js b/server/vitest.config.js
index e279e7e4f9..6780a74836 100644
--- a/server/vitest.config.js
+++ b/server/vitest.config.js
@@ -1,5 +1,11 @@
import { defineConfig } from 'vitest/config';
+// `npm run test:fast` is the Windows-safe way to set the flag (a
+// `VITEST_FAST=1 vitest` script is parsed as an executable name on cmd.exe).
+if (process.env.npm_lifecycle_event === 'test:fast') {
+ process.env.VITEST_FAST = '1';
+}
+
export default defineConfig({
test: {
testTimeout: process.platform === 'win32' ? 30000 : 10000,
@@ -53,6 +59,7 @@ export default defineConfig({
'services/worktreeReap.test.js',
'services/sprites/atlas.test.js',
'services/sprites/walk.test.js',
+ 'lib/gitTestRepo.test.js',
] : []),
],
coverage: {