-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify.mjs
More file actions
43 lines (35 loc) · 1.56 KB
/
Copy pathverify.mjs
File metadata and controls
43 lines (35 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Smoke test for 06-validate-gate. See SUITE.md "06 — validate-gate" for
// the required markers this checks. Runs run.mjs as a subprocess with
// explicit argv paths so it observes the REAL gate exit codes — the
// no-args path is a demo only and always exits 0 (see run.mjs's header).
import path from "node:path";
import { fileURLToPath } from "node:url";
import { spawnSync } from "node:child_process";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
let failures = 0;
function runGate(...paths) {
const result = spawnSync(process.execPath, [path.join(__dirname, "run.mjs"), ...paths], { encoding: "utf-8" });
return [result.status, `${result.stdout}${result.stderr}`];
}
// bad.inky alone -> exit 1, with distinct rule ids present in the output.
const [badExit, badOutput] = runGate(path.join(__dirname, "bad.inky"));
if (badExit !== 1) {
console.error(`06-validate-gate: expected exit 1 for bad.inky, got ${badExit}\n${badOutput}`);
failures++;
}
if (!badOutput.includes("button-no-href")) {
console.error("06-validate-gate: expected rule id 'button-no-href' in output");
failures++;
}
if (!badOutput.includes("missing-preheader")) {
console.error("06-validate-gate: expected rule id 'missing-preheader' in output");
failures++;
}
// good.inky alone -> exit 0.
const [goodExit, goodOutput] = runGate(path.join(__dirname, "good.inky"));
if (goodExit !== 0) {
console.error(`06-validate-gate: expected exit 0 for good.inky, got ${goodExit}\n${goodOutput}`);
failures++;
}
if (failures > 0) process.exit(1);
console.log("06-validate-gate: ok");