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:
32
tests/run-all.js
Normal file
32
tests/run-all.js
Normal 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); });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user