diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Query.zig | 6 | ||||
| -rw-r--r-- | src/config.zig | 34 | ||||
| -rw-r--r-- | src/macos.zig | 2 | ||||
| -rw-r--r-- | src/ninep/ctl.zig | 3 | ||||
| -rw-r--r-- | src/selection_pipe.zig | 4 |
5 files changed, 39 insertions, 10 deletions
diff --git a/src/Query.zig b/src/Query.zig index 09b46f3b..55d7b0b5 100644 --- a/src/Query.zig +++ b/src/Query.zig @@ -2762,7 +2762,7 @@ test "a query row's place is its text: the match tinted after it, B3 on it opens File.setContent(p, &sp.file.?, try p.gpa.dupe(u8, saved)); try std.testing.expect(sp.query == null and sp.file.?.location_rows.len == 0); const at = std.mem.indexOf(u8, saved, "a.txt:2:5").?; - const line = saved[at .. std.mem.indexOfScalarPos(u8, saved, at, '\n').?]; + const line = saved[at..std.mem.indexOfScalarPos(u8, saved, at, '\n').?]; const word = look.expandedWord(line, 3).?; a.body.cur_row = 0; look.lookAt(p, sid, line[word.lo..word.hi]); @@ -2849,7 +2849,9 @@ test "a row's address is the shortest path a Look from the query pane resolves: // Looked at from the pane: the row's file, at its line var realbuf: [4096]u8 = undefined; const t = look.resolve(p, addr, dir, &realbuf); - try std.testing.expectEqualStrings(row.path, t.file.path); + var expected_buf: [4096]u8 = undefined; + const expected = expected_buf[0..try std.Io.Dir.cwd().realPathFile(std.testing.io, row.path, &expected_buf)]; + try std.testing.expectEqualStrings(expected, t.file.path); try std.testing.expectEqual(row.at.line, t.file.at.line); } for ([_][]const u8{ "here.txt:2:1", "sub/deep.txt:2:1", "../up.txt:2:1", far ++ ":1:1" }) |want| { 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; diff --git a/src/macos.zig b/src/macos.zig index 8d372432..4d1d6511 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -2661,7 +2661,7 @@ test "scene effect flags and display clock are compact and independent" { const expectEqual = std.testing.expectEqual; var post: pardes.config.Runtime.Post = .{}; try expectEqual(@as(u32, 0), encodeSceneEffects(&post)); - _ = post.set(.crt, "", true); + _ = post.setLevel(.crt, pardes.config.Runtime.Post.default_level); try expectEqual(scene_flag_crt, encodeSceneEffects(&post)); var st: State = undefined; diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 9cb96667..d0d9b0b4 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -4677,7 +4677,8 @@ test "pager answers its +Pager on the open that asked, whatever another client e try testing.expect(p.paneBySerial(paged) != null); _ = call(p, .{ .tag = 14, .op = .release, .node = pager, .handle = resolved, .opened = true }); // One that may not be written is refused, permission denied. - try testing.expectEqual(E.PERM, wr(p, pager, "/proc/1\n").errno()); + if (comptime @import("builtin").os.tag == .linux) + try testing.expectEqual(E.PERM, wr(p, pager, "/proc/1\n").errno()); // One directory a write, absolute, and there. try testing.expectEqual(E.INVAL, wr(p, pager, "/a\n/b\n").errno()); // One directory an open: one refused is not followed by another, as a diff --git a/src/selection_pipe.zig b/src/selection_pipe.zig index 73bac520..8a43a3af 100644 --- a/src/selection_pipe.zig +++ b/src/selection_pipe.zig @@ -640,7 +640,9 @@ test "a request may give each input its own command and directory, run by the sh var response = runJob(gpa, std.testing.io, job); defer response.deinit(gpa); try std.testing.expect(response.success); - try std.testing.expectEqualStrings("/tmp\n", response.outputs[0]); + var cwd_buf: [std.fs.max_path_bytes]u8 = undefined; + const cwd = cwd_buf[0..try std.Io.Dir.cwd().realPathFile(std.testing.io, "/tmp", &cwd_buf)]; + try std.testing.expectEqualStrings(cwd, std.mem.trimEnd(u8, response.outputs[0], "\n")); try std.testing.expectEqualStrings("ABC", response.outputs[1]); } |
