test: group examples into per-category folders

Move examples/*.sx and their expected/ snapshots into per-category
subfolders (examples/<category>/...). Folder = leading filename token,
with ffi-objc/ffi-jni kept whole; filenames are unchanged. The corpus
runner and LSP sweep now discover each category's expected/ dir, while
issues/ stays flat. Example 1058's repo-root-relative companion import
is made file-relative. Path strings embedded in 164 snapshots were
regenerated (path-only changes). Test-layout docs in CLAUDE.md updated.
This commit is contained in:
agra
2026-06-21 14:41:34 +03:00
parent 6d1409bc1f
commit 66bdc70bf1
3357 changed files with 456 additions and 363 deletions

View File

@@ -38,6 +38,38 @@ fn sweepDirectory(alloc: std.mem.Allocator, io: std.Io, dir: []const u8) !usize
var store = doc_mod.DocumentStore.init(alloc, io, &lib_paths);
store.root_path = std.fs.path.dirname(corpus_paths.examples_dir) orelse "";
// `examples/` is organized into category subdirs (`examples/<cat>/*.sx`),
// while `issues/` is flat (`issues/*.sx`). Sweep the files directly under
// `dir` AND those one level down in each category subdir (skipping the
// `expected/` snapshot dirs). Companion fixture dirs nested deeper
// (`<cat>/<NNNN-...>/lib.sx`) are intentionally not swept — matching the
// pre-reorg behavior where imported companions were never analyzed directly.
var total = try sweepFilesIn(alloc, io, &store, dir, verbose);
var d = std.Io.Dir.openDirAbsolute(io, dir, .{ .iterate = true }) catch return total;
defer d.close(io);
var sub_names: std.ArrayList([]const u8) = .empty;
var it = d.iterate();
while (try it.next(io)) |entry| {
if (entry.kind != .directory) continue;
if (std.mem.eql(u8, entry.name, "expected")) continue;
try sub_names.append(alloc, try alloc.dupe(u8, entry.name));
}
for (sub_names.items) |name| {
const sub = try std.fs.path.join(alloc, &.{ dir, name });
total += sweepFilesIn(alloc, io, &store, sub, verbose) catch 0;
}
return total;
}
/// Analyze every `.sx` directly under `dir` (non-recursive). Returns the count.
fn sweepFilesIn(
alloc: std.mem.Allocator,
io: std.Io,
store: *doc_mod.DocumentStore,
dir: []const u8,
verbose: bool,
) !usize {
const files = store.listDirectoryFiles(dir) orelse return error.CorpusDirNotFound;
for (files) |path| {
if (verbose) std.debug.print("[lsp-sweep] {s}\n", .{path});