test(harness,conversation): pi-fit-tmp re-check 2 round: smoke.test removes the fixture directory conversation/tests/harness.mjs makes when it loads (after(cleanupAll)); with TMPDIR unset that directory now lands in /var/tmp, which a boot doesn't clear, and smoke was the one importer that never removed it; fixtureDir throws a plain line when the temp directory is under /tmp and /var/tmp is missing or under /tmp too, so a test fails on its fixture, not with the fit check's guard line
This commit was merged in pull request #2020.
This commit is contained in:
1 parent
735e828aa2
commit
e035b6dea9
2 files changed
+11
-4
No files matched your search
@@ -21,13 +21,15 @@ import { piFit } from "../../harness/src/pi-fit.mjs";
|
||||
import { locate } from "../../plugins/harness/pi/binary.mjs";
|
||||
import { levels } from "../../plugins/harness/pi/index.mjs";
|
||||
import { FakePi } from "./fake-pi.mjs";
|
||||
import { assistantEntry, header, thinkingEntry, userEntry } from "./harness.mjs";
|
||||
import { assistantEntry, cleanupAll, header, thinkingEntry, userEntry } from "./harness.mjs";
|
||||
|
||||
// The repository's pi: with no MOSAIC_PI_BIN and no PATH the lookup ends there.
|
||||
const REPO_PI = locate({});
|
||||
|
||||
const scratch = mkdtempSync(join(tmpdir(), "chat03-smoke-"));
|
||||
after(() => rmSync(scratch, { recursive: true, force: true }));
|
||||
// harness.mjs makes its fixture directory when it loads; remove it too.
|
||||
after(cleanupAll);
|
||||
|
||||
const COMMANDS = ["get_state", "get_commands", "clear_queue", "abort", "get_tree"];
|
||||
const exchanges = {};
|
||||
|
||||
@@ -93,12 +93,17 @@ import { join } from "node:path";
|
||||
// session's sandbox mounts its private /tmp over it, so a stand-in must not sit there. When the
|
||||
// temp directory's real path is under /tmp (TMPDIR unset, say), the directory goes under /var/tmp
|
||||
// instead; otherwise it goes under tmpdir() as spelled, so a run with TMPDIR elsewhere is unchanged.
|
||||
// With /var/tmp missing or under /tmp too, it throws, so a test fails on its fixture and not with
|
||||
// the guard's line, which would point at the code under test.
|
||||
const underTmp = (p) => /^\/tmp(\/|$)/.test(p);
|
||||
const realOr = (p) => { try { return realpathSync(p); } catch { return null; } };
|
||||
export function fixtureDir(prefix) {
|
||||
let base = tmpdir();
|
||||
try {
|
||||
if (underTmp(realpathSync(base)) && !underTmp(realpathSync("/var/tmp"))) base = "/var/tmp";
|
||||
} catch {}
|
||||
if (underTmp(realOr(base) ?? base)) {
|
||||
const alt = realOr("/var/tmp");
|
||||
if (alt === null || underTmp(alt)) throw new Error("fixtureDir: the temp directory sits under /tmp, where the fit check won't run a pi, and /var/tmp is missing or under /tmp too; set TMPDIR to a directory outside /tmp");
|
||||
base = "/var/tmp";
|
||||
}
|
||||
return mkdtempSync(join(base, prefix));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user