diff --git a/.agents/skills/statechart/scripts/statechart.mjs b/.agents/skills/statechart/scripts/statechart.mjs index 7615e0d..555f10b 100644 --- a/.agents/skills/statechart/scripts/statechart.mjs +++ b/.agents/skills/statechart/scripts/statechart.mjs @@ -24,7 +24,6 @@ import { cannotRunTlc, findTlc } from "./tlc-tools.mjs"; const here = path.dirname(fileURLToPath(import.meta.url)); const { MAX_STRING_LENGTH } = constants; -const tempDir = (prefix) => fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), prefix))); class CannotFinish extends Error {} class TlcStopped extends CannotFinish {} @@ -183,7 +182,7 @@ function runJava(file, args, options, dot) { async function tlc(tools, spec, cfg, base, { dump, module, workers = "1" } = {}) { fs.writeFileSync(`${base}.cfg`, cfg); - const metadir = tempDir("tlc-"); + const metadir = fs.mkdtempSync(path.join(os.tmpdir(), "tlc-")); // TLC writes the standard modules, such as Naturals.tla, to java.io.tmpdir under fixed names, // so runs that share that folder can read a module while another run rewrites it. const javaTmp = path.join(metadir, "tmp"); @@ -609,7 +608,7 @@ function outDir(flagged, input, name) { } async function inWorkFolder(body) { - const work = tempDir("statechart-"); + const work = fs.mkdtempSync(path.join(os.tmpdir(), "statechart-")); fs.mkdirSync(path.join(work, "tlc")); let keep = false; try { diff --git a/.agents/skills/statechart/scripts/test/statechart.test.mjs b/.agents/skills/statechart/scripts/test/statechart.test.mjs index 33198ec..543fe8d 100644 --- a/.agents/skills/statechart/scripts/test/statechart.test.mjs +++ b/.agents/skills/statechart/scripts/test/statechart.test.mjs @@ -8,7 +8,6 @@ import { mkdtempSync, readdirSync, readFileSync, - realpathSync, renameSync, rmSync, statSync, @@ -5845,21 +5844,6 @@ const writeLamp = (dir) => { return join(dir, "Lamp-statechart"); }; -test("a symlinked TMPDIR keeps diagnostic paths relative to the workspace", needsTlc, () => { - const dir = mkdtempSync(join(tmpdir(), "statechart-")); - writeLamp(dir); - const tmp = join(dir, "tmp"); - mkdirSync(tmp); - const alias = join(dir, "alias"); - symlinkSync(tmp, alias, "dir"); - writeFileSync(join(dir, "Lamp.map.mjs"), 'export const state = () => { throw new Error("mapping failed"); };\n'); - const r = node("statechart.mjs", ["from-spec", "Lamp.tla"], dir, { TMPDIR: alias }); - assert.equal(r.status, 2, r.stderr); - const kept = r.stderr.match(/ The files that this run wrote are in (tmp\/statechart-\w+)\.\n$/)?.[1]; - assert.ok(kept, r.stderr); - assert.ok(existsSync(join(dir, kept, "tlc", "Lamp.out"))); -}); - test("a rerun without --png removes the chart.png of an earlier run", needsTlc, () => { const dir = mkdtempSync(join(tmpdir(), "statechart-")); const out = writeLamp(dir); @@ -6176,7 +6160,6 @@ int rename(const char *from, const char *to) { } `; const failingRenames = (() => { - if (process.platform !== "linux") return null; const dir = mkdtempSync(join(tmpdir(), "statechart-preload-")); writeFileSync(join(dir, "rename.c"), failRenames); const so = join(dir, "rename.so"); @@ -6185,7 +6168,7 @@ const failingRenames = (() => { })(); test( "a run whose rename fails after it moves the output folder aside puts the folder back, or says where it is", - { skip: needsTlc.skip || (!failingRenames && "requires Linux LD_PRELOAD and a C compiler") }, + { skip: needsTlc.skip || (!failingRenames && "cannot compile a rename preload") }, () => { const dir = mkdtempSync(join(tmpdir(), "statechart-")); writeLamp(dir); @@ -6221,7 +6204,7 @@ test( test( "a run on a filesystem that cannot rename copies its files into place", - { skip: needsTlc.skip || (!failingRenames && "requires Linux LD_PRELOAD and a C compiler") }, + { skip: needsTlc.skip || (!failingRenames && "cannot compile a rename preload") }, () => { const dir = mkdtempSync(join(tmpdir(), "statechart-")); writeLamp(dir); @@ -6248,7 +6231,7 @@ test( test( "a run that cannot rename replaces a folder that another run makes before its copy, and keeps one that another run makes during its copy", - { skip: needsTlc.skip || (!failingRenames && "requires Linux LD_PRELOAD and a C compiler") }, + { skip: needsTlc.skip || (!failingRenames && "cannot compile a rename preload") }, () => { const dir = mkdtempSync(join(tmpdir(), "statechart-")); writeLamp(dir); @@ -6280,7 +6263,7 @@ test( test( "a run that cannot rename stops when another run removes its folder during its copy and makes an empty one in its place, and keeps that folder", - { skip: needsTlc.skip || (!failingRenames && "requires Linux LD_PRELOAD and a C compiler") }, + { skip: needsTlc.skip || (!failingRenames && "cannot compile a rename preload") }, () => { const dir = mkdtempSync(join(tmpdir(), "statechart-")); writeLamp(dir); @@ -6301,7 +6284,7 @@ test( test( "a run that cannot rename keeps the folder that another run puts in place of its folder as soon as the run makes it", - { skip: needsTlc.skip || (!failingRenames && "requires Linux LD_PRELOAD and a C compiler") }, + { skip: needsTlc.skip || (!failingRenames && "cannot compile a rename preload") }, () => { const dir = mkdtempSync(join(tmpdir(), "statechart-")); writeLamp(dir); @@ -6527,7 +6510,7 @@ exit $s const folders = new Set(); for (const line of runs) { const [folder, parsed] = line.split(": "); - assert.ok(folder.startsWith(join(realpathSync(tmp), "tlc-")), line); + assert.ok(folder.startsWith(join(tmp, "tlc-")), line); assert.ok(parsed.startsWith(`Parsing file ${folder}/`), line); folders.add(folder); } @@ -6552,7 +6535,7 @@ test( const [, file] = r.stderr.match( /^(\S+\/tlc\/Pay\.out): TLC stopped on an error that is not a broken rule: Assumption .* is false\.\n$/, ); - assert.ok(file.startsWith(realpathSync(tmp)), file); + assert.ok(file.startsWith(tmp), file); assert.match(readFileSync(file, "utf8"), /Assumption .* is false/); assert.equal(existsSync(join(dir, "Pay-statechart")), false); }, diff --git a/.agents/skills/statechart/scripts/tlc-tools.mjs b/.agents/skills/statechart/scripts/tlc-tools.mjs index 30a966d..09d46de 100644 --- a/.agents/skills/statechart/scripts/tlc-tools.mjs +++ b/.agents/skills/statechart/scripts/tlc-tools.mjs @@ -21,7 +21,7 @@ export function findTlc() { if (TLA2TOOLS) return { jar: TLA2TOOLS, java: JAVA || "java" }; const command = (tools) => `cd "$(mktemp -d)" && MISE_CEILING_PATHS="$PWD" mise install ${tools.map((t) => `'${t}'`).join(" ")}`; - const empty = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), "statechart-mise-"))); + const empty = fs.mkdtempSync(path.join(os.tmpdir(), "statechart-mise-")); const env = { ...process.env, MISE_CEILING_PATHS: empty }; const run = (...args) => spawnSync("mise", args, { cwd: empty, env, encoding: "utf8" }); const mise = (...args) => {