summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 09:45:38 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commit157df8cb547ba4cf900b1f9eb75df15384985708 (patch)
tree248a415fe9431989e9468ef001a1dd364e249afe /src/ninep/ctl.zig
parent2c03f710535a0b0aa143cd6c1fad04a45857a777 (diff)
downloadpardes-157df8cb547ba4cf900b1f9eb75df15384985708.tar.gz
pardes-157df8cb547ba4cf900b1f9eb75df15384985708.zip
A served-tree pane spoils no Grep, and `look .` from a gone directory is ENOENT
A pane named `/virtual` gave Grep the root `/`, which swallowed every other pane's directory and ran out of walk before any file: every Grep missed. Grep passes over panes of the served tree. And `.` from a pane whose directory was gone resolved to the served tree's root (/virtual/), or through the jump list to another pane's directory: a dot path is the looking pane's own, and gone it fails, `look: <dir>: no such directory`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index db37fa49..d9a479fe 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -2001,6 +2001,31 @@ test "/index shows a name as the log does: a newline in it is \\n, controls spac
try testing.expectEqual(@as(u64, index.len), call(p, .{ .tag = 1, .op = .getattr, .node = @intFromEnum(tree.TopFile.index) }).reply.attr.size);
}
+test "a served-tree pane spoils no Grep, and Look . from a gone directory is ENOENT, not /virtual/" {
+ const p = try withFile(testing.allocator, "x\n");
+ defer p.deinit();
+ var tmp = testing.tmpDir(.{});
+ defer tmp.cleanup();
+ try tmp.dir.writeFile(testing.io, .{ .sub_path = "hit.txt", .data = "needle here\n" });
+ var dir_buf: [4096]u8 = undefined;
+ const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)];
+ var line: [4200]u8 = undefined;
+ _ = wr(p, Node.of(serialOf(p), .name), try std.fmt.bufPrint(&line, "{s}/other.txt\n", .{dir}));
+ // A pane of the served tree.
+ const virtual = try th.newPane(p);
+ _ = wr(p, Node.of(virtual, .name), "/virtual/index\n");
+ // One named the served tree's root, whose directory is `/`.
+ const top = try th.newPane(p);
+ _ = wr(p, Node.of(top, .name), "/virtual\n");
+ try testing.expectEqual(Status.ok, wr(p, Node.of(serialOf(p), .exec), "Grep needle\n").reply.status);
+ // `.` from a pane whose directory is gone.
+ const gone = try th.newPane(p);
+ _ = wr(p, Node.of(gone, .name), "/tmp/pardes-no-such-dir-zz/f.txt\n");
+ const looked = wr(p, Node.of(gone, .look), ".\n");
+ try testing.expectEqual(E.NOENT, looked.errno());
+ try testing.expectStringStartsWith(looked.reply.ename, "look: /tmp/pardes-no-such-dir-zz: no such directory");
+}
+
test "size is monotonic: growing is never refused, and a size once taken is taken again" {
const p = try Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 60 });
defer p.deinit();