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

View File

@@ -27,8 +27,8 @@ export async function run(args) {
rgArgs.push('-g', filePattern);
}
// Add separator and pattern
rgArgs.push('--', pattern);
// Add separator, pattern, and explicit search path '.' so rg scans the chroot cwd
rgArgs.push('--', pattern, '.');
try {
const proc = spawnSync('rg', rgArgs, {
@@ -51,9 +51,13 @@ export async function run(args) {
return `ripgrep error: exit ${proc.status}, ${proc.stderr}`;
}
// Limit to 200 lines
const lines = output.split('\n');
const limitedOutput = lines.slice(0, 200).join('\n');
// Normalize paths (strip leading './') and limit to 200 lines
const lines = output.split('\n').map((l) => l.replace(/^\.\//, ''));
let limitedOutput = lines.slice(0, 200).join('\n');
// Remove a single trailing newline if present to align with tests
if (limitedOutput.endsWith('\n')) {
limitedOutput = limitedOutput.replace(/\n$/, '');
}
return limitedOutput;
} catch (error) {