Skip to content

Instantly share code, notes, and snippets.

@arikon
Created July 27, 2026 23:56
Show Gist options
  • Select an option

  • Save arikon/60f51ff7bc7b39d3a815cbd203c59095 to your computer and use it in GitHub Desktop.

Select an option

Save arikon/60f51ff7bc7b39d3a815cbd203c59095 to your computer and use it in GitHub Desktop.
oh-my-codex #3327: canonicalize macOS temporary test roots
From 7833d067664437c496fd5d33ef50b230d2b62f00 Mon Sep 17 00:00:00 2001
From: Sergey Belov <peimei@ya.ru>
Date: Tue, 28 Jul 2026 01:55:36 +0200
Subject: [PATCH] test: canonicalize macOS temporary roots
---
src/cli/__tests__/auth.test.ts | 5 ++++-
src/cli/__tests__/mcp-parity.test.ts | 6 ++++--
src/cli/__tests__/session-scoped-runtime.test.ts | 6 ++++--
src/cli/__tests__/uninstall.test.ts | 11 +++++++----
src/cli/__tests__/update.test.ts | 6 ++++--
src/hooks/extensibility/__tests__/dispatcher.test.ts | 6 ++++--
src/team/__tests__/scaling.test.ts | 5 +++--
src/ultragoal/__tests__/artifacts.test.ts | 6 ++++--
8 files changed, 34 insertions(+), 17 deletions(-)
diff --git a/src/cli/__tests__/auth.test.ts b/src/cli/__tests__/auth.test.ts
index ab6a92ec..0dbe3b96 100644
--- a/src/cli/__tests__/auth.test.ts
+++ b/src/cli/__tests__/auth.test.ts
@@ -2,10 +2,13 @@ import { describe, it } from "node:test";
import assert from "node:assert/strict";
import { chmod, mkdir, mkdtemp, readFile, realpath, rm, writeFile } from "node:fs/promises";
import { spawnSync } from "node:child_process";
-import { tmpdir } from "node:os";
+import { realpathSync } from "node:fs";
+import { tmpdir as osTmpdir } from "node:os";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
+const tmpdir = (): string => realpathSync(osTmpdir());
+
function omxBin(): string {
const testDir = dirname(fileURLToPath(import.meta.url));
return join(testDir, "..", "..", "..", "dist", "cli", "omx.js");
diff --git a/src/cli/__tests__/mcp-parity.test.ts b/src/cli/__tests__/mcp-parity.test.ts
index a17c155b..06bd097a 100644
--- a/src/cli/__tests__/mcp-parity.test.ts
+++ b/src/cli/__tests__/mcp-parity.test.ts
@@ -1,13 +1,15 @@
import assert from "node:assert/strict";
-import { existsSync } from "node:fs";
+import { existsSync, realpathSync } from "node:fs";
import { chmod, mkdtemp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
-import { tmpdir } from "node:os";
+import { tmpdir as osTmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, describe, it } from "node:test";
import { mcpParityCommand } from "../mcp-parity.js";
import { writeSessionStart } from "../../hooks/session.js";
import { getWikiDir } from "../../wiki/storage.js";
+const tmpdir = (): string => realpathSync(osTmpdir());
+
const originalLog = console.log;
afterEach(() => {
diff --git a/src/cli/__tests__/session-scoped-runtime.test.ts b/src/cli/__tests__/session-scoped-runtime.test.ts
index d6432363..a16a4a42 100644
--- a/src/cli/__tests__/session-scoped-runtime.test.ts
+++ b/src/cli/__tests__/session-scoped-runtime.test.ts
@@ -2,9 +2,9 @@ import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { chmod, mkdir, mkdtemp, rm, symlink, writeFile, readFile } from 'fs/promises';
-import { existsSync } from 'fs';
+import { existsSync, realpathSync } from 'fs';
import { dirname, join } from 'path';
-import { tmpdir } from 'os';
+import { tmpdir as osTmpdir } from 'os';
import { spawnSync } from 'child_process';
import { fileURLToPath } from 'url';
import { readModeState } from '../../modes/base.js';
@@ -12,6 +12,8 @@ import { readSkillActiveState } from '../../state/skill-active.js';
import { recordSkillActivation } from '../../hooks/keyword-detector.js';
import { cancelModesForTest } from '../index.js';
+const tmpdir = (): string => realpathSync(osTmpdir());
+
const testDir = dirname(fileURLToPath(import.meta.url));
const repoRoot = join(testDir, '..', '..', '..');
const omxBin = join(repoRoot, 'dist', 'cli', 'omx.js');
diff --git a/src/cli/__tests__/uninstall.test.ts b/src/cli/__tests__/uninstall.test.ts
index b6b12c06..d1a496a2 100644
--- a/src/cli/__tests__/uninstall.test.ts
+++ b/src/cli/__tests__/uninstall.test.ts
@@ -1,9 +1,9 @@
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { lstat, mkdir, mkdtemp, readFile, readdir, rm, symlink, writeFile } from 'node:fs/promises';
-import { existsSync, lstatSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
+import { existsSync, lstatSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from 'node:fs';
import { basename, dirname, join } from 'node:path';
-import { tmpdir } from 'node:os';
+import { tmpdir as osTmpdir } from 'node:os';
import { spawnSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import {
@@ -15,6 +15,9 @@ import {
import { uninstall } from '../uninstall.js';
import TOML from '@iarna/toml';
+const tmpdir = (): string => realpathSync(osTmpdir());
+const shortTmpdir = (): string => process.platform === 'darwin' ? realpathSync('/tmp') : tmpdir();
+
function runOmx(
cwd: string,
argv: string[],
@@ -1824,7 +1827,7 @@ describe('omx uninstall', () => {
{ name: 'finalization', stage: 'after-staged-cleanup', drift: 'config', committed: true },
] as const;
for (const fixture of fixtures) {
- const wd = await mkdtemp(join(tmpdir(), `omx-uninstall-applied-${fixture.name}-`));
+ const wd = await mkdtemp(join(shortTmpdir(), `omx-uninstall-applied-${fixture.name}-`));
try {
await withCwd(wd, async () => {
const codexDir = join(wd, '.codex');
@@ -3119,7 +3122,7 @@ describe('omx uninstall', () => {
}
});
it('warns once after a successful Windows EPERM-degraded uninstall transaction', async () => {
- const wd = await mkdtemp(join(tmpdir(), 'omx-uninstall-durability-'));
+ const wd = await mkdtemp(join(shortTmpdir(), 'omx-uninstall-durability-'));
const originalStderrWrite = process.stderr.write;
const stderr: string[] = [];
try {
diff --git a/src/cli/__tests__/update.test.ts b/src/cli/__tests__/update.test.ts
index cc552ae1..b3e7acfa 100644
--- a/src/cli/__tests__/update.test.ts
+++ b/src/cli/__tests__/update.test.ts
@@ -1,11 +1,11 @@
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
-import { existsSync } from 'node:fs';
+import { existsSync, realpathSync } from 'node:fs';
import { chmod, mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
import { spawnSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
-import { tmpdir } from 'node:os';
+import { tmpdir as osTmpdir } from 'node:os';
import { dirname, join } from 'node:path';
import {
isInstallVersionBump,
@@ -29,6 +29,8 @@ import {
type PackageManagerOwnership,
} from '../package-manager-ownership.js';
+const tmpdir = (): string => realpathSync(osTmpdir());
+
const PACKAGE_NAME = 'oh-my-codex';
const frozenNpmOwnership: PackageManagerOwnership = {
manager: 'npm',
diff --git a/src/hooks/extensibility/__tests__/dispatcher.test.ts b/src/hooks/extensibility/__tests__/dispatcher.test.ts
index 8c7197fc..ec7361e7 100644
--- a/src/hooks/extensibility/__tests__/dispatcher.test.ts
+++ b/src/hooks/extensibility/__tests__/dispatcher.test.ts
@@ -1,12 +1,14 @@
import assert from 'node:assert/strict';
-import { existsSync } from 'node:fs';
+import { existsSync, realpathSync } from 'node:fs';
import { mkdtemp, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
-import { tmpdir } from 'node:os';
+import { tmpdir as osTmpdir } from 'node:os';
import { delimiter, join } from 'node:path';
import { describe, it } from 'node:test';
import { isHookPluginFeatureEnabled, dispatchHookEvent } from '../dispatcher.js';
import { buildHookEvent } from '../events.js';
+const tmpdir = (): string => realpathSync(osTmpdir());
+
function processExists(pid: number): boolean {
try {
process.kill(pid, 0);
diff --git a/src/team/__tests__/scaling.test.ts b/src/team/__tests__/scaling.test.ts
index f9214c9d..658cb5df 100644
--- a/src/team/__tests__/scaling.test.ts
+++ b/src/team/__tests__/scaling.test.ts
@@ -4,8 +4,8 @@ import { createHash } from 'node:crypto';
import { execFileSync } from 'node:child_process';
import { mkdtemp, rm, readFile, writeFile, mkdir, chmod, readdir, symlink } from 'fs/promises';
import { join, posix, relative, win32 } from 'path';
-import { tmpdir } from 'os';
-import { existsSync, readFileSync } from 'fs';
+import { tmpdir as osTmpdir } from 'os';
+import { existsSync, readFileSync, realpathSync } from 'fs';
import {
initTeamState,
createTask,
@@ -32,6 +32,7 @@ import {
import { TEAM_WORKER_INHERITED_MODEL_ENV } from '../model-contract.js';
import { buildWorkerProcessLaunchSpec } from '../tmux-session.js';
+const tmpdir = (): string => realpathSync(osTmpdir());
delete process.env.OMX_TEAM_STATE_ROOT;
process.env.OMX_RUNTIME_BRIDGE = '0';
diff --git a/src/ultragoal/__tests__/artifacts.test.ts b/src/ultragoal/__tests__/artifacts.test.ts
index c7240b48..1d76520e 100644
--- a/src/ultragoal/__tests__/artifacts.test.ts
+++ b/src/ultragoal/__tests__/artifacts.test.ts
@@ -1,9 +1,9 @@
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
-import { existsSync } from 'node:fs';
+import { existsSync, realpathSync } from 'node:fs';
import { join } from 'node:path';
-import { tmpdir } from 'node:os';
+import { tmpdir as osTmpdir } from 'node:os';
import {
__resetSessionPointerTransactionDependenciesForTests,
__setSessionPointerTransactionDependenciesForTests,
@@ -30,6 +30,8 @@ import {
import { LEADER_CONDUCTOR_BLOCK, buildUnsupportedNativeSubagentGuidance } from '../../leader/contract.js';
import { steeringFixtures, type SteeringFixtureProposal } from './steering-fixtures.js';
+const tmpdir = (): string => realpathSync(osTmpdir());
+
async function withTempRepo<T>(run: (cwd: string) => Promise<T>): Promise<T> {
const cwd = await mkdtemp(join(tmpdir(), 'omx-ultragoal-'));
try {
--
2.50.1 (Apple Git-155)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment