feat(FN-5189): complete Step 5 — guard against nohup regressions
Fusion-Task-Id: FN-5189 Fusion-Task-Lineage: 4caa3f0a-af81-4c60-88e8-de229ed72e08
This commit is contained in:
committed by
gsxdsm
parent
dc8dd33f80
commit
8c05682ab4
28
scripts/__tests__/check-no-nohup.test.mjs
Normal file
28
scripts/__tests__/check-no-nohup.test.mjs
Normal file
@@ -0,0 +1,28 @@
|
||||
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/);
|
||||
});
|
||||
Reference in New Issue
Block a user