Repository navigation
Expand file tree
/
Copy pathrun-all.mjs
More file actions
45 lines (38 loc) · 1.46 KB
/
Copy pathrun-all.mjs
File metadata and controls
45 lines (38 loc) · 1.46 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
44
45
// Runs every example in examples/*/run.mjs, in order.
// --verify additionally checks each example's required output markers.
import fs from "node:fs";
import path from "node:path";
import { spawnSync } from "node:child_process";
import { ROOT } from "./bootstrap.mjs";
const verify = process.argv.includes("--verify");
let failures = 0;
const examplesDir = path.join(ROOT, "examples");
const names = fs
.readdirSync(examplesDir)
.filter((n) => fs.statSync(path.join(examplesDir, n)).isDirectory())
.sort();
for (const name of names) {
const script = path.join(examplesDir, name, "run.mjs");
if (!fs.existsSync(script)) continue;
console.log(`\n=== ${name} ===`);
const result = spawnSync(process.execPath, [script], { stdio: "inherit" });
// 06 demonstrates a failing gate on purpose; its run.mjs manages its own
// exit codes when given explicit argv paths, but the no-args suite-runner
// path always exits 0 (see that example's run.mjs header comment).
if (result.status !== 0 && name !== "06-validate-gate") {
console.error(`FAILED: ${name} (exit ${result.status})`);
failures++;
continue;
}
if (verify) {
const check = path.join(examplesDir, name, "verify.mjs");
if (fs.existsSync(check)) {
const vresult = spawnSync(process.execPath, [check], { stdio: "inherit" });
if (vresult.status !== 0) {
console.error(`VERIFY FAILED: ${name}`);
failures++;
}
}
}
}
process.exit(failures === 0 ? 0 : 1);