Fix syntax errors in compiler and clean up debug output
This commit is contained in:
parent
35a4fb7fef
commit
80caf6412c
19 changed files with 243 additions and 0 deletions
42
simple-test-runner.js
Normal file
42
simple-test-runner.js
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#!/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);
|
||||
Loading…
Add table
Add a link
Reference in a new issue