summaryrefslogtreecommitdiff
path: root/test/image_harness.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 05:19:21 -0300
committerGabriel Schneider <[email protected]>2026-11-06 05:55:49 -0300
commitc8553032ef84aec74cbb5d07d07f934eecf3d4a9 (patch)
treee47d3dd72b83e0b95d53271df9f5932dab389959 /test/image_harness.zig
parentde0447471febe1253b42a32fe9a1d6cdccc9d5b9 (diff)
downloadpardes-c8553032ef84aec74cbb5d07d07f934eecf3d4a9.tar.gz
pardes-c8553032ef84aec74cbb5d07d07f934eecf3d4a9.zip
kinds #9, the core's image code gone: src/image.zig (558 lines) and the static table go, so no kind is compiled in (Registry.init, Kind.image, compiledIn, `static` in /addons and "is compiled in" with them) and a test of the core's side of a kind's pane opens Kind.test_kind (a picture of one pixel, no library); a placement's fit (NativeGeometry, containGeometry) moves to surface.zig and a PDF's fit modes to pdf_view.zig; a terminal's kitty PNG decodes in TerminalImages.zig through wuffs as before, its downscale through stb_image_resize, the one part of zstbi the core keeps (stb_image patched out of it, the wuffs_images option, tag_image and image_exts gone); the image cases load the built image.so by path: test/panes.zig's and fs_namespace's through Addon.perform, T1 through Addon load (a new behaviour case: PNG, JPEG and PPM through 9P, the art words, a refused corrupt PNG, a dump's placeholder and its picture back, which replaces the decode unit test and ctl.zig's corrupt-image case), the snapshot, process and image harnesses by linking it into each session's data directory; images.snap unchanged
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/image_harness.zig')
-rw-r--r--test/image_harness.zig20
1 files changed, 15 insertions, 5 deletions
diff --git a/test/image_harness.zig b/test/image_harness.zig
index 18392851..02e6690b 100644
--- a/test/image_harness.zig
+++ b/test/image_harness.zig
@@ -36,12 +36,14 @@ pub fn main(init: std.process.Init) !void {
defer arena_state.deinit();
const arena = arena_state.allocator();
const args = try init.minimal.args.toSlice(arena);
- if (args.len != 3 and args.len != 4) return error.BadArgs;
+ // <pardes> <image.so> tui|gui [pdf]
+ if (args.len != 4 and args.len != 5) return error.BadArgs;
const exe = try arena.dupeSentinel(u8, args[1], 0);
- const backend = args[2];
- const pdf_mode = args.len == 4 and std.mem.eql(u8, args[3], "pdf");
- if (args.len == 4 and !pdf_mode) return error.BadArgs;
+ const image_addon = try std.Io.Dir.cwd().realPathFileAlloc(init.io, args[2], arena);
+ const backend = args[3];
+ const pdf_mode = args.len == 5 and std.mem.eql(u8, args[4], "pdf");
+ if (args.len == 5 and !pdf_mode) return error.BadArgs;
const base = try std.fmt.allocPrintSentinel(arena, "/tmp/pardes-image-harness-{d}", .{libc.getpid()}, 0);
if (libc.mkdir(base, 0o755) != 0 and libc.errno(-1) != .EXIST) return error.MkdirFailed;
defer cleanupBase(arena, base);
@@ -54,6 +56,10 @@ pub fn main(init: std.process.Init) !void {
const config_dir = try std.fmt.allocPrintSentinel(arena, "{s}/pardes", .{config_home}, 0);
if (libc.mkdir(config_dir, 0o755) != 0) return error.MkdirFailed;
try eh.writeFile(try std.fmt.allocPrintSentinel(arena, "{s}/init", .{config_dir}, 0), "Theme helix\n");
+ // Its data directory too, holding the image addon its start scan loads.
+ _ = setenv("XDG_DATA_HOME", try std.fmt.allocPrintSentinel(arena, "{s}/data", .{base}, 0), 1);
+ for ([_][]const u8{ "data", "data/pardes", "data/pardes/addons" }) |sub| _ = libc.mkdir(try std.fmt.allocPrintSentinel(arena, "{s}/{s}", .{ base, sub }, 0), 0o755);
+ if (libc.symlink(image_addon, try std.fmt.allocPrintSentinel(arena, "{s}/data/pardes/addons/image.so", .{base}, 0)) != 0) return error.SymlinkFailed;
_ = setenv("HISTFILE", "/dev/null", 1);
_ = setenv("TERM", "xterm-256color", 1);
_ = setenv("LC_ALL", "C", 1);
@@ -78,11 +84,15 @@ fn cleanupBase(arena: std.mem.Allocator, base: [:0]const u8) void {
_ = libc.rmdir(config_dir);
const config_home = std.fmt.allocPrintSentinel(arena, "{s}/.config", .{base}, 0) catch return;
_ = libc.rmdir(config_home);
- const names = [_][]const u8{ "native.ppm", "pages.pdf", "latest.ppm", "latest.ppm.tmp", ".bash_history" };
+ const names = [_][]const u8{ "native.ppm", "pages.pdf", "latest.ppm", "latest.ppm.tmp", ".bash_history", "data/pardes/addons/image.so" };
for (names) |name| {
const path = std.fmt.allocPrintSentinel(arena, "{s}/{s}", .{ base, name }, 0) catch continue;
_ = libc.unlink(path);
}
+ for ([_][]const u8{ "data/pardes/addons", "data/pardes", "data" }) |sub| {
+ const path = std.fmt.allocPrintSentinel(arena, "{s}/{s}", .{ base, sub }, 0) catch continue;
+ _ = libc.rmdir(path);
+ }
_ = libc.rmdir(base);
}