mirror of
https://github.com/earendil-works/pi.git
synced 2026-06-18 15:54:04 +08:00
fix(coding-agent): use physical temp paths in session-id-readonly test
On macOS tmpdir() is a symlink (/var -> /private/var) while the spawned CLI's process.cwd() is physical, so session cwd filtering never matched the fixtures and the fork-target rejection test failed locally.
This commit is contained in:
@@ -1,5 +1,14 @@
|
||||
import { spawn } from "node:child_process";
|
||||
import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import {
|
||||
existsSync,
|
||||
mkdirSync,
|
||||
mkdtempSync,
|
||||
readdirSync,
|
||||
readFileSync,
|
||||
realpathSync,
|
||||
rmSync,
|
||||
writeFileSync,
|
||||
} from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join, resolve } from "node:path";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
@@ -15,7 +24,10 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
function createTempDir(): string {
|
||||
const dir = mkdtempSync(join(tmpdir(), "pi-session-id-readonly-"));
|
||||
// realpath: on macOS tmpdir() is a symlink (/var -> /private/var), but the
|
||||
// spawned CLI sees the physical path via process.cwd(). Session cwd
|
||||
// filtering compares paths textually, so the fixture must use physical paths.
|
||||
const dir = realpathSync(mkdtempSync(join(tmpdir(), "pi-session-id-readonly-")));
|
||||
tempDirs.push(dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user