42 lines
No EOL
1.1 KiB
JavaScript
42 lines
No EOL
1.1 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import fs from "node:fs/promises";
|
|
|
|
async function main() {
|
|
const testFiles = await fs.readdir("./tests");
|
|
const cFiles = testFiles.filter(file => file.endsWith(".c"));
|
|
|
|
let passed = 0;
|
|
let failed = 0;
|
|
|
|
console.log(`Running ${cFiles.length} tests...\n`);
|
|
|
|
for (const cFile of cFiles) {
|
|
try {
|
|
console.log(`Testing ${cFile}...`);
|
|
const { spawn } = await import("node:child_process");
|
|
const child = spawn("node", ["index.js", `tests/${cFile}`], { cwd: "." });
|
|
|
|
child.on("close", (code) => {
|
|
if (code === 0) {
|
|
console.log(` ✓ ${cFile} passed`);
|
|
passed++;
|
|
} else {
|
|
console.log(` ✗ ${cFile} failed with code ${code}`);
|
|
failed++;
|
|
}
|
|
});
|
|
|
|
child.stderr.on("data", (data) => {
|
|
console.error(` Error: ${data.toString()}`);
|
|
});
|
|
} catch (error) {
|
|
console.log(` ✗ ${cFile} failed with exception: ${error.message}`);
|
|
failed++;
|
|
}
|
|
}
|
|
|
|
console.log(`\nResults: ${passed} passed, ${failed} failed`);
|
|
}
|
|
|
|
main().catch(console.error); |