From 6aa66eea2ca1fa7174e8427ef209a73b7364f64b Mon Sep 17 00:00:00 2001 From: Nicky Leach Date: Wed, 15 Jul 2026 18:07:00 +0000 Subject: [PATCH] test: cover codex auth sync-back chmod ordering Co-authored-by: Paperclip --- .../adapter-utils/src/sandbox-managed-runtime.test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/adapter-utils/src/sandbox-managed-runtime.test.ts b/packages/adapter-utils/src/sandbox-managed-runtime.test.ts index 80c47b5a311..37d71efd380 100644 --- a/packages/adapter-utils/src/sandbox-managed-runtime.test.ts +++ b/packages/adapter-utils/src/sandbox-managed-runtime.test.ts @@ -2,6 +2,7 @@ import { lstat, mkdir, mkdtemp, readFile, readdir, realpath, rm, stat, symlink, import os from "node:os"; import path from "node:path"; import { execFile as execFileCallback } from "node:child_process"; +import { promises as fs } from "node:fs"; import { promisify } from "node:util"; import { afterEach, describe, expect, it, vi } from "vitest"; import { resetLocalGitIndexToHead } from "./git-workspace-sync.js"; @@ -263,6 +264,13 @@ describe("sandbox managed runtime", () => { await symlink(hostAuthSource, path.join(localCodexHome, "auth.json")); const client = createLocalSandboxClient(); + const realChmod = fs.chmod.bind(fs); + const chmodSpy = vi.spyOn(fs, "chmod").mockImplementation(async (target, mode) => { + if (target === hostAuthSource) { + throw Object.assign(new Error("post-rename chmod should not run"), { code: "EACCES" }); + } + await realChmod(target, mode); + }); const lines: string[] = []; const runtimeStatuses: string[] = []; const prepared = await prepareSandboxManagedRuntime({ @@ -307,6 +315,7 @@ describe("sandbox managed runtime", () => { } finally { polling = false; await pollPromise; + chmodSpy.mockRestore(); } expect(invalidReads).toEqual([]);