diff options
Diffstat (limited to 'src/ninep/ctl.zig')
| -rw-r--r-- | src/ninep/ctl.zig | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 1ef9a2f6..330b9cb7 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -1819,6 +1819,29 @@ test "a builtin that needs its argument, written bare to an exec, is EINVAL as t } } +test "Grep with no hit says grep: no match and opens nothing, a missing pane directory passed over" { + 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 = "a.txt", .data = "alpha\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}/a.txt\n", .{dir})); + // A second pane in a directory that is not there. + const other = try th.newPane(p); + _ = wr(p, Node.of(other, .name), "/tmp/pardes-no-such-dir-zz/b.txt\n"); + var count: usize = 0; + for (p.panes) |slot| count += @intFromBool(slot != null); + const missed = wr(p, Node.of(serialOf(p), .exec), "Grep zzqqnomatchzz\n"); + try testing.expectEqual(E.IO, missed.errno()); + try testing.expectEqualStrings("grep: no match", missed.reply.ename); + var after: usize = 0; + for (p.panes) |slot| after += @intFromBool(slot != null); + try testing.expectEqual(count, after); +} + 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(); |
