Enhance testing framework by introducing a unified test runner in run-all.js, allowing for streamlined execution of multiple test scripts. Update package.json to include new test commands for individual test scripts and the consolidated runner. Add comprehensive test cases for list_files, read_file, and ripgrep functionalities, improving overall test coverage and error handling.

This commit is contained in:
sebseb7
2025-08-11 23:05:14 +02:00
parent 8645909fd5
commit 15d8e96b49
6 changed files with 534 additions and 6 deletions

32
tests/run-all.js Normal file
View File

@@ -0,0 +1,32 @@
#!/usr/bin/env node
import { spawn } from 'node:child_process';
import path from 'node:path';
const tests = [
'tests/run-tests.js',
'tests/run-readfile-tests.js',
'tests/run-listfiles-tests.js',
'tests/run-ripgrep-tests.js',
];
function runOne(scriptPath) {
return new Promise((resolve) => {
const abs = path.resolve(process.cwd(), scriptPath);
const child = spawn(process.execPath, [abs], { stdio: 'inherit' });
child.on('close', (code) => resolve({ script: scriptPath, code }));
child.on('error', (err) => resolve({ script: scriptPath, code: 1, error: err }));
});
}
async function main() {
let anyFailed = false;
for (const t of tests) {
const res = await runOne(t);
if (res.code !== 0) anyFailed = true;
}
process.exit(anyFailed ? 1 : 0);
}
main().catch((err) => { console.error('Fatal error in run-all:', err); process.exit(1); });