Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

test(windows): make platform fixtures deterministic (#403)

oleg-ai-dev60043e09bb94
diff --git a/test/cli-install-ladder.test.cjs b/test/cli-install-ladder.test.cjs
index 24f96095..2672afba 100644
--- a/test/cli-install-ladder.test.cjs
+++ b/test/cli-install-ladder.test.cjs
@@ -14,7 +14,9 @@ const loadTs = require('./load-ts.cjs');
const { chooseInstallRung, buildMissingCliScript } = loadTs('src/main/cliInstall.ts');
const { installInfoForProvider } = loadTs('src/shared/agentProvider.ts');
-const script = (provider, npmAvailable, platform) =>
+// Most assertions below exercise the multi-line POSIX script. Keep them
+// deterministic on every host; the dedicated Windows test passes win32 itself.
+const script = (provider, npmAvailable, platform = 'linux') =>
buildMissingCliScript(provider, provider, npmAvailable, platform);
test('with npm present the ladder is unchanged — npm install, for every provider', () => {
@@ -68,7 +70,7 @@ test('the no-node script explains the real problem instead of failing at it', ()
test('the native rung actually runs, and says why it differs', () => {
const out = script('claude', false);
assert.match(out, /no Node needed/);
- const native = installInfoForProvider('claude').nativeCommand;
+ const native = installInfoForProvider('claude', 'linux').nativeCommand;
assert.ok(out.split('\n').includes(native), 'the installer must be an executed line, not only echoed');
});
@@ -94,7 +96,7 @@ test('the Windows script stays a single quote-free cmd.exe line', () => {
test('a hostile binary name cannot inject a command into the banner', () => {
const out = script('claude', true).split('\n');
- const evil = buildMissingCliScript("x'; rm -rf /; echo '", 'claude', true).split('\n');
+ const evil = buildMissingCliScript("x'; rm -rf /; echo '", 'claude', true, 'linux').split('\n');
assert.equal(evil.length, out.length, 'no extra statements');
assert.ok(evil.some((l) => l.includes('xrm-rf')), 'sanitized to a bare identifier');
assert.ok(!evil.some((l) => /rm -rf \//.test(l)));
diff --git a/test/codex-remote.test.cjs b/test/codex-remote.test.cjs
index 7f46d50f..c6b333bf 100644
--- a/test/codex-remote.test.cjs
+++ b/test/codex-remote.test.cjs
@@ -13,7 +13,9 @@ const {
CODEX_REMOTE_SOCKET_RELATIVE
} = loadTs('src/shared/codexRemote.ts');
-test('Codex remote uses a short stable per-agent home alias', () => {
+test('Codex remote uses a short stable per-agent home alias', {
+ skip: process.platform === 'win32' ? 'Codex remote uses Unix sockets and is disabled on Windows' : false
+}, () => {
const first = codexRemoteAliasPath('/very/long/hive/agent/.codex', 'dev-1', '/tmp');
const again = codexRemoteAliasPath('/very/long/hive/agent/.codex', 'dev-1', '/tmp');
const other = codexRemoteAliasPath('/very/long/hive/agent/.codex', 'dev-2', '/tmp');
diff --git a/test/transcript-project-dir.test.cjs b/test/transcript-project-dir.test.cjs
index 0b85f35b..f3d51616 100644
--- a/test/transcript-project-dir.test.cjs
+++ b/test/transcript-project-dir.test.cjs
@@ -3,9 +3,6 @@
// Originally contributed by Vyapak Goyal (@gts-47) in #123, extended here with
// the dotted-path cases that the first version's dot-free fixtures could not
// catch.
-//
-// POSIX-only: projectDir() resolves against os.homedir(), which these cases
-// redirect via $HOME — a knob Windows does not honour.
const test = require('node:test');
const assert = require('node:assert/strict');
@@ -16,12 +13,13 @@ const loadTs = require('./load-ts.cjs');
const { projectDir } = loadTs('src/main/transcript.ts');
-/** projectDir() resolves against os.homedir(), which POSIX reads from $HOME — so
- * each case gets a throwaway home and never touches the real ~/.claude. */
+/** Give projectDir() a throwaway home so no case touches the real ~/.claude.
+ * os.homedir() reads HOME on POSIX and USERPROFILE on Windows. */
function withHome(run) {
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'md-transcript-'));
- const prev = process.env.HOME;
- process.env.HOME = home;
+ const homeEnv = process.platform === 'win32' ? 'USERPROFILE' : 'HOME';
+ const prev = process.env[homeEnv];
+ process.env[homeEnv] = home;
try {
return run(home, (key) => {
const dir = path.join(home, '.claude/projects', key);
@@ -29,12 +27,16 @@ function withHome(run) {
return dir;
});
} finally {
- if (prev === undefined) delete process.env.HOME;
- else process.env.HOME = prev;
+ if (prev === undefined) delete process.env[homeEnv];
+ else process.env[homeEnv] = prev;
fs.rmSync(home, { recursive: true, force: true });
}
}
+const posixLegacyOnly = {
+ skip: process.platform === 'win32' ? 'the pre-2026 legacy key existed only on POSIX' : false
+};
+
test('an unseen cwd resolves to the CURRENT key, leading slash dashed', () => {
withHome(() => {
// The regression: this used to return 'Users-me-app', a directory Claude Code
@@ -90,14 +92,14 @@ test('the dotted legacy twin loses to the dotted current spelling', () => {
});
});
-test('a legacy-only install still resolves, so old transcripts stay readable', () => {
+test('a legacy-only install still resolves, so old transcripts stay readable', posixLegacyOnly, () => {
withHome((_home, mkProject) => {
const legacy = mkProject('Users-me-app');
assert.equal(projectDir('/Users/me/app'), legacy);
});
});
-test('a legacy-only install with dots resolves to its undashed twin', () => {
+test('a legacy-only install with dots resolves to its undashed twin', posixLegacyOnly, () => {
withHome((_home, mkProject) => {
// The legacy key kept dots, so the fallback has to keep them too — deriving
// it from the new key by stripping the leading dash would look for