Skip to content

Commit c75b574

Browse files
justrachclaude
andcommitted
test: regression coverage for #447 (skip-trigram canonical file surfaces)
ab8f7cd's Tier 0 rewrite already fixes #447 implicitly — Tier 0 now builds candidates directly from word_index.search, which captures hits in skip_trigram_files alongside fully-indexed files. The new test pins this behavior so a future Tier 0 refactor cannot silently regress. (PR #456's structural fix on top of the old code is obviated; closing.) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3d7381b commit c75b574

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

src/tests.zig

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11244,6 +11244,46 @@ test "issue-451: scope search surfaces skip-trigram canonical file" {
1124411244
try testing.expect(found_canonical);
1124511245
}
1124611246

11247+
test "issue-447: searchContent surfaces large (>64KB) skip-trigram files for common identifiers" {
11248+
var arena = std.heap.ArenaAllocator.init(testing.allocator);
11249+
defer arena.deinit();
11250+
var explorer = Explorer.init(arena.allocator());
11251+
11252+
var i: usize = 0;
11253+
while (i < 12) : (i += 1) {
11254+
var path_buf: [32]u8 = undefined;
11255+
const path = try std.fmt.bufPrint(&path_buf, "small_{d}.zig", .{i});
11256+
try explorer.indexFile(path, "fn s() void { _ = widgetX; }\n");
11257+
}
11258+
11259+
const canonical_content =
11260+
"fn canonical() void {\n" ++
11261+
" _ = widgetX;\n" ++
11262+
" _ = widgetX;\n" ++
11263+
" _ = widgetX;\n" ++
11264+
" _ = widgetX;\n" ++
11265+
" _ = widgetX;\n" ++
11266+
"}\n";
11267+
try explorer.indexFileSkipTrigram("canonical.zig", canonical_content);
11268+
11269+
const results = try explorer.searchContent("widgetX", testing.allocator, 5);
11270+
defer {
11271+
for (results) |r| {
11272+
testing.allocator.free(r.line_text);
11273+
testing.allocator.free(r.path);
11274+
}
11275+
testing.allocator.free(results);
11276+
}
11277+
11278+
var found_canonical = false;
11279+
for (results) |r| {
11280+
if (std.mem.eql(u8, r.path, "canonical.zig")) found_canonical = true;
11281+
}
11282+
try testing.expect(found_canonical);
11283+
}
11284+
11285+
11286+
1124711287
test "rerank-trace: appends one JSON line per searchContent when enabled" {
1124811288
const tmp_io = testing.io;
1124911289
var tmp = testing.tmpDir(.{});

0 commit comments

Comments
 (0)