summaryrefslogtreecommitdiff
path: root/test/snapshot.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-08-16 15:49:12 -0300
committerGabriel Schneider <[email protected]>2026-08-18 23:44:42 -0300
commit1551e409c31992437cb2fa864f576d45c8433801 (patch)
treee2fae8451f87b735a1360c7c2e383fdc40165789 /test/snapshot.zig
parentbe2a9957708cbf0c478ca861c4a1f0f227bbfe10 (diff)
downloadpardes-1551e409c31992437cb2fa864f576d45c8433801.tar.gz
pardes-1551e409c31992437cb2fa864f576d45c8433801.zip
big slow change: prebuilt shaders (SPIR-V/Metal), core gui reflow, docs, web + snapshot refresh
Diffstat (limited to 'test/snapshot.zig')
-rw-r--r--test/snapshot.zig17
1 files changed, 15 insertions, 2 deletions
diff --git a/test/snapshot.zig b/test/snapshot.zig
index c3611291..18fc2093 100644
--- a/test/snapshot.zig
+++ b/test/snapshot.zig
@@ -4,7 +4,7 @@
// the old-vs-new parity oracle for the rewrite.
//
// zig build snap run all snapshots/*.snap, diff goldens
-// zig build snap -- --update regenerate goldens from this binary
+// zig build snap -- --update regenerate goldens serially
// zig build snap -- snapshots/boot.snap one script
// zig build snap -- --jobs=1 serial (default: 1.25 per cpu)
// zig build snap -- --trace-stable show what every `stable` waited on
@@ -105,6 +105,13 @@ pub fn main(init: std.process.Init) !void {
script_count += 1;
}
}
+ // Updating is the one run whose output becomes evidence instead of being
+ // checked against it. The ordinary parallel pass can reject a transient
+ // capture and retry it alone; update mode has no expected bytes to compare,
+ // so it cannot know which capture needs that retry. Run it serially even if
+ // --jobs was supplied: a slower intentional baseline refresh is cheaper
+ // than blessing scheduler or shared-process startup noise as behavior.
+ if (update) jobs = 1;
var scripts = try arena.alloc([]const u8, script_count);
var script_i: usize = 0;
var saw_exe = false;
@@ -262,6 +269,13 @@ fn runOne(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const u8
}
const base_path = script_path[0 .. script_path.len - ".snap".len];
const golden_path = std.fmt.allocPrint(arena, "{s}.golden", .{base_path}) catch return 1;
+ // `.actual` means THIS invocation failed. Passing runs used to leave an
+ // ignored file from an older failure behind, making a clean suite look
+ // 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;
+ _ = libc.unlink(actual_path_z);
const golden: ?[]u8 = readFileAlloc(arena, golden_path) catch null;
const started = eh.nowMs();
const out = runScript(arena, exe_z, script_path, stem) catch |e| {
@@ -282,7 +296,6 @@ 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;
}
- const actual_path = std.fmt.allocPrint(arena, "{s}.actual", .{base_path}) catch return 1;
eh.writeFile(arena.dupeZ(u8, actual_path) catch return 1, out) catch {};
std.debug.print("FAIL {s}: differs from golden (actual written to {s})\n", .{ stem, actual_path });
printFirstDiff(golden.?, out);