From e179cc44fe5060c76a5b00c41e53f11209f5acd9 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 30 Oct 2026 17:44:26 -0300 Subject: Repair macOS validation after the upstream update Keep cross-platform documentation metadata alive only during its owning test, and recognize leaders from the other platform's published builtin lists. Use canonical filesystem paths on Darwin, keep the procfs permission assertion Linux-specific, and set the scene's level through the current API. --- src/config.zig | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'src/config.zig') diff --git a/src/config.zig b/src/config.zig index 988f634d..7ed3972c 100644 --- a/src/config.zig +++ b/src/config.zig @@ -2207,6 +2207,16 @@ const doc_typ = struct { /// may name a window-only word in a terminal build's test, and back. var other_build: []const u8 = ""; + fn loadOtherBuilds(gpa: std.mem.Allocator) !void { + other_build = ""; + var dir = try std.Io.Dir.cwd().openDir(std.testing.io, @import("doc_typ").dir, .{}); + defer dir.close(std.testing.io); + for ([_][]const u8{ "builtins-tty.json", "builtins-gui.json" }) |f| { + const text = dir.readFileAlloc(std.testing.io, f, gpa, .limited(1 << 20)) catch continue; + other_build = try std.mem.concat(gpa, u8, &.{ other_build, text }); + } + } + fn word(w: []const u8) bool { const name = w[0 .. std.mem.indexOfScalar(u8, w, '+') orelse w.len]; if (std.meta.stringToEnum(Builtin, name) != null) return true; @@ -2277,7 +2287,9 @@ const doc_typ = struct { for (std.enums.values(Builtin)) |b| if (leader_path.get(b)) |p| if (std.mem.eql(u8, p, path[0..n])) return true; for (leader_args) |la| if (std.mem.eql(u8, la.path, path[0..n])) return true; - return false; + var buf: [96]u8 = undefined; + const needle = std.fmt.bufPrint(&buf, "\"leader\": \"{s}\"", .{k}) catch return false; + return std.mem.indexOf(u8, other_build, needle) != null; } toks.reset(); while (toks.next()) |t| if (!bound(chord(t) orelse return false)) return false; @@ -2306,10 +2318,8 @@ test "docs/typ names only words, keys and default tags that exist" { var dir = try std.Io.Dir.cwd().openDir(io, @import("doc_typ").dir, .{ .iterate = true }); defer dir.close(io); var found: [3]std.ArrayList([]const u8) = @splat(.empty); - for ([_][]const u8{ "builtins-tty.json", "builtins-gui.json" }) |f| { - const text = dir.readFileAlloc(io, f, gpa, .limited(1 << 20)) catch continue; - doc_typ.other_build = try std.mem.concat(gpa, u8, &.{ doc_typ.other_build, text }); - } + try doc_typ.loadOtherBuilds(gpa); + defer doc_typ.other_build = ""; var it = dir.iterate(); while (try it.next(io)) |entry| if (entry.kind == .file and std.mem.endsWith(u8, entry.name, ".typ")) { const source = try dir.readFileAlloc(io, entry.name, gpa, .limited(1 << 20)); @@ -2374,6 +2384,18 @@ const doc_tutor = struct { for (std.enums.values(Builtin)) |b| if (leader_path.get(b)) |p| if (std.mem.startsWith(u8, p, keys)) return true; for (leader_args) |la| if (std.mem.startsWith(u8, la.path, keys)) return true; + var leaders = std.mem.splitSequence(u8, doc_typ.other_build, "\"leader\": \"SPC "); + _ = leaders.next(); + while (leaders.next()) |tail| { + const end = std.mem.indexOfScalar(u8, tail, '"') orelse continue; + var compact: [8]u8 = undefined; + var n: usize = 0; + for (tail[0..end]) |c| if (c != ' ' and n < compact.len) { + compact[n] = c; + n += 1; + }; + if (std.mem.startsWith(u8, compact[0..n], keys)) return true; + } return false; } @@ -2405,6 +2427,8 @@ test "the tutor names only words, keys, paths and default tags that exist" { var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); defer arena.deinit(); const gpa = arena.allocator(); + try doc_typ.loadOtherBuilds(gpa); + defer doc_typ.other_build = ""; const tutor = @embedFile("tutor.txt"); var found: std.ArrayList([]const u8) = .empty; -- cgit v1.3