Files
clide/test/files/pql_config_test.dart
T
jpmschweitzerandClaude Opus 4.8 d7be5535d5 drive workspace ignore from ignore_files:, add files.walk
Replace the hardcoded .gitignore + .clideignore read with the ordered
ignore_files: chain from .pql/config.yaml (D-4) — the single ignore
knob clide owns (D-3). readIgnoreFiles defaults to .gitignore (plus
.clideignore when present) when the config is absent or malformed, and
honours an explicit [] as "no file-based exclusions".

Add walkFiles + the files.walk command: a recursive, ignore-pruned,
capped flat file listing reused by quick-open (T-51) and the search
engine (T-52). Closes the never-filed ignore-layering placeholder in
files_commands.dart.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-31 20:08:34 +02:00

64 lines
2.0 KiB
Dart

/// Tests for `readIgnoreFiles` — resolving the clide-owned
/// `ignore_files:` key from `.pql/config.yaml` (D-3 / D-4).
library;
import 'dart:io';
import 'package:clide/src/files/pql_config.dart';
import 'package:test/test.dart';
void main() {
late Directory root;
setUp(() async {
root = await Directory.systemTemp.createTemp('clide-pqlconfig-');
});
tearDown(() async {
if (root.existsSync()) root.deleteSync(recursive: true);
});
void writeConfig(String body) {
Directory('${root.path}/.pql').createSync();
File('${root.path}/.pql/config.yaml').writeAsStringSync(body);
}
test('no config → defaults to [.gitignore]', () {
expect(readIgnoreFiles(root), ['.gitignore']);
});
test('no config but .clideignore present → adds it after .gitignore', () {
File('${root.path}/.clideignore').writeAsStringSync('build/\n');
expect(readIgnoreFiles(root), ['.gitignore', '.clideignore']);
});
test('explicit ignore_files list is honoured verbatim and in order', () {
writeConfig('ignore_files: [.gitignore, .pqlignore]\n');
expect(readIgnoreFiles(root), ['.gitignore', '.pqlignore']);
});
test('explicit empty list disables file-based exclusions', () {
writeConfig('ignore_files: []\n');
expect(readIgnoreFiles(root), isEmpty);
});
test('config present but key absent → default (ignores .clideignore rule only via default)', () {
writeConfig('frontmatter: yaml\n');
expect(readIgnoreFiles(root), ['.gitignore']);
});
test('non-string entries are dropped from the list', () {
writeConfig('ignore_files: [.gitignore, 42, .pqlignore]\n');
expect(readIgnoreFiles(root), ['.gitignore', '.pqlignore']);
});
test('malformed YAML falls back to the default (never throws)', () {
writeConfig('ignore_files: [unterminated\n:::bad');
expect(readIgnoreFiles(root), ['.gitignore']);
});
test('ignore_files set to a scalar (not a list) falls back to default', () {
writeConfig('ignore_files: .gitignore\n');
expect(readIgnoreFiles(root), ['.gitignore']);
});
}