| 123456789101112131415161718192021222324252627 |
- #!/usr/bin/env node
- import { spawnSync } from "node:child_process";
- import { readdirSync } from "node:fs";
- import { dirname, join, resolve } from "node:path";
- import { fileURLToPath } from "node:url";
- const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
- function collectTests(directory) {
- const result = [];
- for (const entry of readdirSync(directory, { withFileTypes: true })) {
- if (entry.name === "node_modules") continue;
- const fullPath = join(directory, entry.name);
- if (entry.isDirectory()) result.push(...collectTests(fullPath));
- else if (entry.isFile() && entry.name.endsWith(".test.mjs")) result.push(fullPath);
- }
- return result;
- }
- const tests = collectTests(root);
- const child = spawnSync(process.execPath, ["--test", ...tests], {
- cwd: root,
- stdio: "inherit",
- encoding: "utf8",
- maxBuffer: 1024 * 1024 * 100,
- });
- process.exit(child.status ?? 1);
|