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
69
test-current.js
Normal file
69
test-current.js
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
// Test what we have working right now
|
||||
|
||||
import fs from "node:fs/promises";
|
||||
import { spawn } from "node:child_process";
|
||||
|
||||
async function runTest(testName) {
|
||||
try {
|
||||
console.log(`\nTesting ${testName}...`);
|
||||
const child = spawn("node", ["index.js", `tests/${testName}`], { cwd: "." });
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let stderr = '';
|
||||
|
||||
child.stderr.on("data", (data) => {
|
||||
stderr += data.toString();
|
||||
});
|
||||
|
||||
child.on("close", (code) => {
|
||||
if (code === 0) {
|
||||
console.log(` ✓ ${testName} - PASSED`);
|
||||
resolve({ name: testName, passed: true });
|
||||
} else {
|
||||
console.log(` ✗ ${testName} - FAILED (exit code ${code})`);
|
||||
if (stderr) {
|
||||
console.log(` Error: ${stderr.substring(0, 100)}...`);
|
||||
}
|
||||
resolve({ name: testName, passed: false, error: stderr });
|
||||
}
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(` ✗ ${testName} - EXCEPTION: ${error.message}`);
|
||||
return { name: testName, passed: false, error: error.message };
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const testFiles = await fs.readdir("./tests");
|
||||
const testNames = testFiles.filter(file => file.endsWith(".c"));
|
||||
|
||||
console.log(`\nRunning current tests (${testNames.length} total)`);
|
||||
|
||||
let results = [];
|
||||
|
||||
for (const testName of testNames) {
|
||||
const result = await runTest(testName);
|
||||
results.push(result);
|
||||
}
|
||||
|
||||
const passed = results.filter(r => r.passed).length;
|
||||
const failed = results.length - passed;
|
||||
|
||||
console.log(`\nResults: ${passed} passed, ${failed} failed`);
|
||||
|
||||
if (failed === 0) {
|
||||
console.log("All tests passed! ✓");
|
||||
} else {
|
||||
console.log("Some tests failed! ✗");
|
||||
}
|
||||
|
||||
console.log("\nFailed tests:");
|
||||
results.filter(r => !r.passed).forEach(r => {
|
||||
console.log(` - ${r.name}`);
|
||||
});
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
Loading…
Add table
Add a link
Reference in a new issue