diff options
Diffstat (limited to 'src/ninep/ctl.zig')
| -rw-r--r-- | src/ninep/ctl.zig | 64 |
1 files changed, 2 insertions, 62 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 3176ebc8..1b9d73f5 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -2075,8 +2075,7 @@ test "Zerox twins dump their text once and come back on one buffer from a Restor try pardes.dump.dumpState(p); const text = p.dump_out.?; // The text is kept once though three panes show it. - const encoded = try pardes.dump.encodeBytes(p.scratch.allocator(), p.panes[0].?.file.?.content); - try testing.expectEqual(@as(usize, 1), std.mem.count(u8, text, encoded)); + try testing.expectEqual(@as(usize, 1), std.mem.count(u8, text, p.panes[0].?.file.?.content)); const restored = try pardes.dump.restore(p, text, "/tmp/pardes.dump.zon"); defer restored.deinit(); var files: [3]*pardes.panes.File.State = undefined; @@ -2838,7 +2837,7 @@ test "a Restore of a file that is no dump fails the write before any warning, an const root_ctl = @backingInt(tree.TopFile.ctl); const refused = wr(p, root_ctl, line); try testing.expectEqual(E.IO, refused.errno()); - try testing.expect(std.mem.indexOf(u8, refused.reply.ename, "not a pardes dump: line 1: ") != null); + try testing.expect(std.mem.indexOf(u8, refused.reply.ename, "not a pardes dump: it does not begin as one") != null); try testing.expect(p.restore_req == null); try testing.expect(p.panes[0].?.discard_warned == null); @@ -4899,46 +4898,6 @@ test "Petscii, Palette and Ascii take the state their tag word names, set rather try testing.expect(th.logHas(p, "Petscii takes on or off")); } -test "a Restore reads a clean file from disk; an unsaved one whose file changed since is said so, and its first Save asks" { - if (comptime !pardes.hosted) return; - const gpa = testing.allocator; - var tmp = testing.tmpDir(.{}); - defer tmp.cleanup(); - try tmp.dir.writeFile(testing.io, .{ .sub_path = "a.txt", .data = "one\n" }); - var dir_buf: [4096]u8 = undefined; - const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)]; - var path_buf: [4200]u8 = undefined; - const path = try std.fmt.bufPrint(&path_buf, "{s}/a.txt", .{dir}); - const p = try Pardes.init(gpa, .{ .file = path, .tty_only = true, .cols = 80, .rows = 24 }); - defer p.deinit(); - // Clean: the dump keeps no text, and the newer disk is what comes back. - try pardes.dump.dumpState(p); - try testing.expect(std.mem.indexOf(u8, p.dump_out.?, "b25lCg==") == null); // "one\n" in base64 - try tmp.dir.writeFile(testing.io, .{ .sub_path = "a.txt", .data = "two\n" }); - { - const restored = try pardes.dump.restore(p, p.dump_out.?, "/tmp/pardes.dump.zon"); - defer restored.deinit(); - const f = pane_files.fileOf(restored.panes[0].?).?; - try testing.expectEqualStrings("two\n", f.content); - try testing.expectEqual(f.saved_revision, f.revision); - } - // Unsaved: its text comes back, the disk changed under it is said, and - // Save asks once before overwriting it. - const f = pane_files.fileOf(p.panes[0].?).?; - const edited = try gpa.dupe(u8, "edited\n"); - pardes.panes.File.setContent(p, f, edited); - try testing.expect(f.revision != f.saved_revision); - try pardes.dump.dumpState(p); - try tmp.dir.writeFile(testing.io, .{ .sub_path = "a.txt", .data = "three\n" }); - const restored = try pardes.dump.restore(p, p.dump_out.?, "/tmp/pardes.dump.zon"); - defer restored.deinit(); - const rf = pane_files.fileOf(restored.panes[0].?).?; - try testing.expectEqualStrings("edited\n", rf.content); - try testing.expect(rf.disk_newer != null); - pardes.exec.saveFile(restored, 0); - try testing.expect(th.logHas(restored, "modified on disk since read (Save again to overwrite)")); -} - test "a Rename the server answered for this file alone, with other open files saying the name, is previewed and says so" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); @@ -5086,25 +5045,6 @@ test "a command or a terminal refused for room is refused before anything is log } } -test "an unsaved pane from a dump that says nothing of its disk asks at its first Save" { - if (comptime !pardes.hosted) return; - const gpa = testing.allocator; - var tmp = testing.tmpDir(.{}); - defer tmp.cleanup(); - try tmp.dir.writeFile(testing.io, .{ .sub_path = "old.txt", .data = "disk\n" }); - var dir_buf: [4096]u8 = undefined; - const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)]; - var path_buf: [4200]u8 = undefined; - const path = try std.fmt.bufPrint(&path_buf, "{s}/old.txt", .{dir}); - const p = try withFile(gpa, "x\n"); - defer p.deinit(); - const id = p.freeSlot().?; - const pane = try pardes.panes.File.restore(p, id, .{ .kind = .file, .tag = "", .body = "", .file = .{ .path = path, .content = "unsaved\n", .dirty = true } }); - try testing.expect(pane.file.?.disk_newer != null); - pardes.exec.saveFile(p, id); - try testing.expect(th.logHas(p, "modified on disk since read (Save again to overwrite)")); -} - test "a Mount of a socket path that is not there says no such socket, ENOENT" { if (comptime !pardes.hosted) return; const p = try withFile(testing.allocator, "x\n"); |
