summaryrefslogtreecommitdiff
path: root/test/snapshot.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-21 14:35:15 -0300
committerGabriel Schneider <[email protected]>2026-10-22 10:03:15 -0300
commitbc3d18d27f9fc1155db7fac3946c4d38774f9e65 (patch)
tree9178ce95952797f8a78b16c2b805e53368efb35a /test/snapshot.zig
parent1ecb9b720840ea8e4753823fa8cddcf5d6a3a4d2 (diff)
downloadpardes-bc3d18d27f9fc1155db7fac3946c4d38774f9e65.tar.gz
pardes-bc3d18d27f9fc1155db7fac3946c4d38774f9e65.zip
Build with Zig 0.17
ghostty, libvaxis and uucode move to ghostty's 0.17 pins, cloud9 to its 0.17 main, SDL to castholm's release-3.4.x (3.4.18), zstbi and tree-sitter to forks with 0.17 build files (see build.zig.zon). A bare zig build copies the binaries into ~/.local/bin (-Dhome-install=false leaves it out): 0.17 keeps the prefix from build scripts. A terminal's edited copy goes when the program clears the screen. tinywin.snap is gone; perf baselines are re-recorded. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'test/snapshot.zig')
-rw-r--r--test/snapshot.zig40
1 files changed, 20 insertions, 20 deletions
diff --git a/test/snapshot.zig b/test/snapshot.zig
index 5522fbb9..2d8a8664 100644
--- a/test/snapshot.zig
+++ b/test/snapshot.zig
@@ -157,8 +157,8 @@ pub fn main(init: std.process.Init) !void {
script_i += 1;
}
if (exe == null) fatal("usage: pardes-snap <exe> [scripts...] [--update] [--jobs=N]", .{});
- const exe_z = try arena.dupeZ(u8, exe.?);
- lspmock_bin = if (lspmock) |p| try arena.dupeZ(u8, p) else null;
+ const exe_z = try arena.dupeSentinel(u8, exe.?, 0);
+ lspmock_bin = if (lspmock) |p| try arena.dupeSentinel(u8, p, 0) else null;
if (scripts.len == 0) {
scripts = try listSnaps(arena, try absPath(arena, orig_cwd, "test/snapshots"));
@@ -443,7 +443,7 @@ fn runBatch(
fn runOne(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const u8, update: bool) u8 {
if (careful) beCareful();
const stem = std.fs.path.stem(script_path);
- const report_z = arena.dupeZ(u8, reportPath(arena, script_path) catch return 1) catch return 1;
+ const report_z = arena.dupeSentinel(u8, reportPath(arena, script_path) catch return 1, 0) catch return 1;
const fd = libc.open(report_z, .{ .ACCMODE = .WRONLY, .CREAT = true, .TRUNC = true }, @as(libc.mode_t, 0o644));
if (fd >= 0) {
_ = libc.dup2(fd, 1);
@@ -457,7 +457,7 @@ fn runOne(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const u8
// dirty to every manual `cmp` audit. Unlink only this script's exact path
// before it starts; a new mismatch below writes it back.
const actual_path = std.fmt.allocPrint(arena, "{s}.actual", .{base_path}) catch return 1;
- const actual_path_z = arena.dupeZ(u8, actual_path) catch return 1;
+ const actual_path_z = arena.dupeSentinel(u8, actual_path, 0) catch return 1;
if (record_dir == null) _ = libc.unlink(actual_path_z);
const golden: ?[]u8 = if (record_dir == null) readFileAlloc(arena, golden_path) catch null else null;
const started = eh.nowMs();
@@ -473,7 +473,7 @@ fn runOne(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const u8
return 0;
}
if (update) {
- eh.writeFile(arena.dupeZ(u8, golden_path) catch return 1, out) catch return 1;
+ eh.writeFile(arena.dupeSentinel(u8, golden_path, 0) catch return 1, out) catch return 1;
std.debug.print("UPDATED {s} ({d} bytes)\n", .{ stem, out.len });
return 0;
}
@@ -485,7 +485,7 @@ fn runOne(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const u8
std.debug.print("PASS {s} ({d}ms)\n", .{ stem, took });
return 0;
}
- eh.writeFile(arena.dupeZ(u8, actual_path) catch return 1, out) catch |err| {
+ eh.writeFile(arena.dupeSentinel(u8, actual_path, 0) catch return 1, out) catch |err| {
std.debug.print("FAIL {s}: differs from golden; cannot write {s}: {s} ({d}ms)\n", .{ stem, actual_path, @errorName(err), took });
printFirstDiff(golden.?, out);
return 1;
@@ -557,7 +557,7 @@ fn runScript(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const
try mkdir(arena, work, false);
// deterministic shell: fixed prompt, no history, no user rc leakage
try eh.writeFile(try std.fmt.allocPrintSentinel(arena, "{s}/.bashrc", .{home}, 0), "PS1='$ '\nHISTFILE=\n");
- _ = setenv("HOME", try arena.dupeZ(u8, home), 1);
+ _ = setenv("HOME", try arena.dupeSentinel(u8, home, 0), 1);
// Keep startup configuration hermetic even when the developer exports an
// XDG directory that points outside this per-snapshot fake home.
const config_home = try std.fmt.allocPrintSentinel(arena, "{s}/.config", .{home}, 0);
@@ -602,8 +602,8 @@ fn runScript(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const
// take turns — which cost more wall clock than the other 51 scripts put
// together. Scripts name it `$DUMP`.
const dump_path = try std.fmt.allocPrint(arena, "{s}/dump.zon", .{base});
- _ = setenv("PARDES_DUMP", try arena.dupeZ(u8, dump_path), 1);
- if (chdirRc(try arena.dupeZ(u8, work)) < 0) return error.ChdirFailed;
+ _ = setenv("PARDES_DUMP", try arena.dupeSentinel(u8, dump_path, 0), 1);
+ if (chdirRc(try arena.dupeSentinel(u8, work, 0)) < 0) return error.ChdirFailed;
const chunks = try arena.alloc([]const u8, countCaptures(src));
var chunk_len: usize = 0;
@@ -636,7 +636,7 @@ fn runScript(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const
try eh.appendFile(try std.fmt.allocPrintSentinel(arena, "{s}/pardes/init", .{config_home}, 0), setting);
} else if (std.mem.eql(u8, cmd, "file")) {
const name = tok.next() orelse return error.BadScript;
- try eh.writeFile(try arena.dupeZ(u8, name), try unescape(arena, tok.rest()));
+ try eh.writeFile(try arena.dupeSentinel(u8, name, 0), try unescape(arena, tok.rest()));
} else if (std.mem.eql(u8, cmd, "lines")) {
const name = tok.next() orelse return error.BadScript;
const n = try std.fmt.parseInt(usize, tok.next() orelse return error.BadScript, 10);
@@ -646,7 +646,7 @@ fn runScript(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const
// scroll test needs and `file` can only give as one huge script line
const tail = tok.rest();
const buf = try numberedLines(arena, n, tail);
- try eh.writeFile(try arena.dupeZ(u8, name), buf);
+ try eh.writeFile(try arena.dupeSentinel(u8, name, 0), buf);
} else if (std.mem.eql(u8, cmd, "ppmdiag")) {
// The diagonal-split test PPM from the old e2e (white over blue),
// grown to 512x512 with the white half filled by a fixed LCG
@@ -658,7 +658,7 @@ fn runScript(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const
// down to flat color and a block always wins).
const name = tok.next() orelse return error.BadScript;
const ppm = try ppmDiag(arena);
- try eh.writeFile(try arena.dupeZ(u8, name), ppm);
+ try eh.writeFile(try arena.dupeSentinel(u8, name, 0), ppm);
} else if (std.mem.eql(u8, cmd, "dirmk")) {
try mkdir(arena, tok.next() orelse return error.BadScript, false);
} else if (std.mem.eql(u8, cmd, "run")) {
@@ -668,7 +668,7 @@ fn runScript(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const
// different inotify event. This runs in the script's cwd, as a
// child of the RUNNER, so nothing it does reaches the app's ptys:
// whatever the app then shows, it woke up for by itself.
- if (system(try arena.dupeZ(u8, tok.rest())) != 0) return error.RunFailed;
+ if (system(try arena.dupeSentinel(u8, tok.rest(), 0)) != 0) return error.RunFailed;
} else if (std.mem.eql(u8, cmd, "start")) {
const rows = try std.fmt.parseInt(u16, tok.next() orelse return error.BadScript, 10);
const cols = try std.fmt.parseInt(u16, tok.next() orelse return error.BadScript, 10);
@@ -676,7 +676,7 @@ fn runScript(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const
var nextra: usize = 0;
while (tok.next()) |a| : (nextra += 1) {
if (nextra >= extra.len) return error.BadScript;
- extra[nextra] = (try arena.dupeZ(u8, a)).ptr;
+ extra[nextra] = (try arena.dupeSentinel(u8, a, 0)).ptr;
}
if (h) |*hp| hp.deinit(); // scripts may restart (e.g. dump then -l)
// a new process is a new screen: capture it whole, or its first
@@ -963,13 +963,13 @@ fn treeAsleep(root: libc.pid_t) bool {
while (n > 0) {
n -= 1;
const pid = stack[n];
- const dir_path = std.fmt.bufPrintZ(&path_buf, "/proc/{d}/task", .{pid}) catch continue;
+ const dir_path = std.fmt.bufPrintSentinel(&path_buf, "/proc/{d}/task", .{pid}, 0) catch continue;
const dir = libc.opendir(dir_path) orelse continue; // exited between steps
defer _ = libc.closedir(dir);
while (libc.readdir(dir)) |d| {
const tid = std.mem.sliceTo(@as([*:0]const u8, @ptrCast(&d.name)), 0);
if (tid[0] == '.') continue;
- const stat = readProc(&buf, std.fmt.bufPrintZ(&path_buf, "/proc/{d}/task/{s}/stat", .{ pid, tid }) catch continue) orelse continue;
+ const stat = readProc(&buf, std.fmt.bufPrintSentinel(&path_buf, "/proc/{d}/task/{s}/stat", .{ pid, tid }, 0) catch continue) orelse continue;
// "pid (comm) S ..." — comm can hold spaces and parens, so the
// state is the char two past the LAST ')'
const close = std.mem.lastIndexOfScalar(u8, stat, ')') orelse continue;
@@ -983,7 +983,7 @@ fn treeAsleep(root: libc.pid_t) bool {
'R', 'D', 'Z' => return false,
else => {},
}
- const kids = readProc(&buf, std.fmt.bufPrintZ(&path_buf, "/proc/{d}/task/{s}/children", .{ pid, tid }) catch continue) orelse continue;
+ const kids = readProc(&buf, std.fmt.bufPrintSentinel(&path_buf, "/proc/{d}/task/{s}/children", .{ pid, tid }, 0) catch continue) orelse continue;
var it = std.mem.tokenizeAny(u8, kids, " \n");
while (it.next()) |k| {
if (n >= stack.len) return false; // deeper than we can walk: assume busy
@@ -1554,7 +1554,7 @@ fn absPath(arena: std.mem.Allocator, cwd: []const u8, p: []const u8) ![]const u8
}
fn listSnaps(arena: std.mem.Allocator, dir_path: []const u8) ![][]const u8 {
- const dir_z = try arena.dupeZ(u8, dir_path);
+ const dir_z = try arena.dupeSentinel(u8, dir_path, 0);
const count = countSnapEntries(dir_z, dir_path);
const scripts = try arena.alloc([]const u8, count);
const dir = libc.opendir(dir_z) orelse fatal("no snapshots/ dir at {s}", .{dir_path});
@@ -1583,7 +1583,7 @@ fn countSnapEntries(dir_z: [:0]const u8, dir_path: []const u8) usize {
}
fn readFileAlloc(arena: std.mem.Allocator, path: []const u8) ![]u8 {
- const path_z = try arena.dupeZ(u8, path);
+ const path_z = try arena.dupeSentinel(u8, path, 0);
const fd = libc.open(path_z, .{ .ACCMODE = .RDONLY });
if (fd < 0) return error.OpenFailed;
defer _ = libc.close(fd);
@@ -1611,7 +1611,7 @@ fn readFileAlloc(arena: std.mem.Allocator, path: []const u8) ![]u8 {
}
fn mkdir(arena: std.mem.Allocator, path: []const u8, exist_ok: bool) !void {
- const path_z = try arena.dupeZ(u8, path);
+ const path_z = try arena.dupeSentinel(u8, path, 0);
const rc = libc.mkdir(path_z, 0o755);
if (rc != 0) {
if (exist_ok and libc.errno(rc) == .EXIST) return;