summaryrefslogtreecommitdiff
path: root/src/upgrade.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/upgrade.zig')
-rw-r--r--src/upgrade.zig25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/upgrade.zig b/src/upgrade.zig
index 212a8176..b4003aa6 100644
--- a/src/upgrade.zig
+++ b/src/upgrade.zig
@@ -470,3 +470,28 @@ test "an upgrade's record reads back as it was written, and refuses one cut shor
try std.testing.expectError(error.BadRecord, Record.decode("link 5\n"));
try std.testing.expectError(error.BadRecord, Record.decode("tty 0 1 2 1 abc\ndump x\n"));
}
+
+test "an upgrade from the build before reads the dump file its record names, and deletes it once loaded" {
+ const gpa = std.testing.allocator;
+ const p = try pardes.Pardes.init(gpa, .{ .tty_only = true });
+ defer p.deinit();
+ _ = try p.setTestFile("before the upgrade\n");
+ const bytes = try pardes.dump.byteDump(p);
+ defer gpa.free(bytes);
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "pardes-upgrade-1.dump", .data = bytes });
+ var dir_buf: [4096]u8 = undefined;
+ const dir = dir_buf[0..try tmp.dir.realPath(std.testing.io, &dir_buf)];
+ var text_buf: [4300]u8 = undefined;
+ // The build before's record: its dump a file, no label.
+ var rec = try Record.decode(try std.fmt.bufPrint(&text_buf, "link -1\nstub -1\nold -1\nwindow 0\nexe /x/pardes\ndump {s}/pardes-upgrade-1.dump\n", .{dir}));
+ const q = try load(gpa, gpa, .{ .tty_only = true }, &rec);
+ defer q.deinit();
+ try std.testing.expect(!rec.fresh);
+ const text = for (q.panes) |slot| {
+ if (slot) |pane| if (pane.file) |f| if (f.output == null) break f.content;
+ } else return error.FileLost;
+ try std.testing.expectEqualStrings("before the upgrade\n", text);
+ try std.testing.expectError(error.FileNotFound, tmp.dir.statFile(std.testing.io, "pardes-upgrade-1.dump", .{}));
+}