Enhance test coverage by adding new cases for file listing, reading, and ripgrep functionalities. Implement tests for hidden files, depth handling, and path normalization in list_files tests. Expand read_file tests to cover line skipping and reading from empty files. Improve ripgrep tests with various pattern matching scenarios, including regex handling and file pattern exclusions.

This commit is contained in:
sebseb7
2025-08-11 23:07:59 +02:00
parent 15d8e96b49
commit b91c4bf5e7
4 changed files with 133 additions and 0 deletions

View File

@@ -124,6 +124,46 @@ function cases() {
expect: { errorRegex: /Path does not exist:/ }
});
// 7. Hidden excluded when includeHidden=false
list.push({
name: 'hidden excluded by default',
before: { '.hidden': 'h', 'shown.txt': 's' },
args: async ({ dir }) => ({ path: path.relative(chrootRoot, dir) || '/', depth: 1, includeHidden: false }),
expect: { cwdFromArgs: true, files: [['shown.txt', 'f', 1]] }
});
// 8. Depth 0 shows only top-level entries
list.push({
name: 'depth 0 top-level only',
before: { 'a.txt': 'A', 'sub/b.txt': 'B' },
args: async ({ dir }) => ({ path: path.relative(chrootRoot, dir) || '/', depth: 0, includeHidden: false }),
expect: { cwdFromArgs: true, files: [['a.txt', 'f', 1], ['sub', 'd', null]] }
});
// 9. Pass hidden file path with includeHidden=false (excluded)
list.push({
name: 'hidden file path excluded when flag false',
before: { '.only.txt': 'x' },
args: async ({ dir }) => ({ path: path.relative(chrootRoot, path.join(dir, '.only.txt')), depth: 1, includeHidden: false }),
expect: { cwdFromArgs: 'file', files: [] }
});
// 10. Pass hidden file path with includeHidden=true (included)
list.push({
name: 'hidden file path included when flag true',
before: { '.only.txt': 'x' },
args: async ({ dir }) => ({ path: path.relative(chrootRoot, path.join(dir, '.only.txt')), depth: 1, includeHidden: true }),
expect: { cwdFromArgs: 'file', files: [['.only.txt', 'f', 1]] }
});
// 11. Path normalization outside chroot -> error
list.push({
name: 'outside chroot error',
before: {},
args: async () => ({ path: '../../etc', depth: 1, includeHidden: false }),
expect: { errorRegex: /Path escapes chroot boundary/ }
});
return list;
}