Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions pstack/skills/statechart/scripts/test/statechart.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import {
mkdtempSync,
readdirSync,
readFileSync,
realpathSync,
renameSync,
rmSync,
statSync,
symlinkSync,
utimesSync,
writeFileSync,
} from "node:fs";
import { tmpdir } from "node:os";
import { tmpdir as osTmpdir } from "node:os";
import { basename, delimiter, dirname, join, posix, win32 } from "node:path";
import { test } from "node:test";
import { setTimeout as sleep } from "node:timers/promises";
Expand Down Expand Up @@ -47,6 +48,7 @@ import { ruleBook } from "../rule-book.mjs";
import { copyPath } from "../snapshot.mjs";
import { findTlc, JAVA_TOOL, TLC_TOOL } from "../tlc-tools.mjs";

const tmpdir = () => realpathSync(osTmpdir());
const here = dirname(fileURLToPath(import.meta.url));
const scripts = dirname(here);
const fixture = (name) => readFileSync(join(here, name), "utf8");
Expand Down Expand Up @@ -6160,6 +6162,7 @@ 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");
Expand All @@ -6168,7 +6171,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 && "cannot compile a rename preload") },
{ skip: needsTlc.skip || (!failingRenames && "needs LD_PRELOAD on Linux, or cannot compile a rename preload") },
() => {
const dir = mkdtempSync(join(tmpdir(), "statechart-"));
writeLamp(dir);
Expand Down Expand Up @@ -6204,7 +6207,7 @@ test(

test(
"a run on a filesystem that cannot rename copies its files into place",
{ skip: needsTlc.skip || (!failingRenames && "cannot compile a rename preload") },
{ skip: needsTlc.skip || (!failingRenames && "needs LD_PRELOAD on Linux, or cannot compile a rename preload") },
() => {
const dir = mkdtempSync(join(tmpdir(), "statechart-"));
writeLamp(dir);
Expand All @@ -6231,7 +6234,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 && "cannot compile a rename preload") },
{ skip: needsTlc.skip || (!failingRenames && "needs LD_PRELOAD on Linux, or cannot compile a rename preload") },
() => {
const dir = mkdtempSync(join(tmpdir(), "statechart-"));
writeLamp(dir);
Expand Down Expand Up @@ -6263,7 +6266,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 && "cannot compile a rename preload") },
{ skip: needsTlc.skip || (!failingRenames && "needs LD_PRELOAD on Linux, or cannot compile a rename preload") },
() => {
const dir = mkdtempSync(join(tmpdir(), "statechart-"));
writeLamp(dir);
Expand All @@ -6284,7 +6287,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 && "cannot compile a rename preload") },
{ skip: needsTlc.skip || (!failingRenames && "needs LD_PRELOAD on Linux, or cannot compile a rename preload") },
() => {
const dir = mkdtempSync(join(tmpdir(), "statechart-"));
writeLamp(dir);
Expand Down