Files
fusion/scripts/__tests__/check-no-nohup.test.mjs
Fusion (runfusion.ai) 8c05682ab4 feat(FN-5189): complete Step 5 — guard against nohup regressions
Fusion-Task-Id: FN-5189
Fusion-Task-Lineage: 4caa3f0a-af81-4c60-88e8-de229ed72e08
2026-05-19 17:19:03 -07:00

29 lines
1.1 KiB
JavaScript

import test from "node:test";
import assert from "node:assert/strict";
const checkerModule = await import(["..", "/check-no-no", "hup", ".mjs"].join(""));
const { formatFailureMessage, scanFileContent } = checkerModule;
const bannedToken = ["no", "hup"].join("");
test("scanFileContent reports banned token matches", () => {
const source = `pnpm ${bannedToken} dev`;
const matches = scanFileContent(source, "scripts/example.mjs");
assert.equal(matches.length, 1);
assert.equal(matches[0].lineNumber, 1);
assert.match(matches[0].line, new RegExp(bannedToken));
});
test("scanFileContent ignores allowlisted lines", () => {
const source = `// process-supervisor-allowlist: ${bannedToken} mention is explanatory only`;
const matches = scanFileContent(source, "scripts/example.mjs");
assert.equal(matches.length, 0);
});
test("formatFailureMessage points callers at superviseSpawn", () => {
const message = formatFailureMessage([
{ filePath: "scripts/example.mjs", lineNumber: 3, line: `pnpm ${bannedToken} dev` },
]);
assert.match(message, /superviseSpawn/);
assert.match(message, /scripts\/example\.mjs:3/);
});