test: dedupe utility and config suites

This commit is contained in:
Peter Steinberger
2026-03-28 00:26:10 +00:00
parent d8f97358d7
commit fef688fb7a
24 changed files with 1178 additions and 1312 deletions

View File

@@ -6,18 +6,15 @@ import {
} from "./exec-inline-eval.js";
describe("exec inline eval detection", () => {
it("detects common interpreter eval flags", () => {
const cases = [
{ argv: ["python3", "-c", "print('hi')"], expected: "python3 -c" },
{ argv: ["/usr/bin/node", "--eval", "console.log('hi')"], expected: "node --eval" },
{ argv: ["perl", "-E", "say 1"], expected: "perl -e" },
{ argv: ["osascript", "-e", "beep"], expected: "osascript -e" },
];
for (const testCase of cases) {
const hit = detectInterpreterInlineEvalArgv(testCase.argv);
expect(hit).not.toBeNull();
expect(describeInterpreterInlineEval(hit!)).toBe(testCase.expected);
}
it.each([
{ argv: ["python3", "-c", "print('hi')"], expected: "python3 -c" },
{ argv: ["/usr/bin/node", "--eval", "console.log('hi')"], expected: "node --eval" },
{ argv: ["perl", "-E", "say 1"], expected: "perl -e" },
{ argv: ["osascript", "-e", "beep"], expected: "osascript -e" },
] as const)("detects interpreter eval flags for %j", ({ argv, expected }) => {
const hit = detectInterpreterInlineEvalArgv([...argv]);
expect(hit).not.toBeNull();
expect(describeInterpreterInlineEval(hit!)).toBe(expected);
});
it("ignores normal script execution", () => {