summaryrefslogtreecommitdiff
path: root/test/image_harness.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-11 12:38:56 -0300
committerGabriel Schneider <[email protected]>2026-09-15 17:24:42 -0300
commit682e237df7e8b22f820d14a4adee58e6e2f84268 (patch)
tree5d888cb46f1a49e89fc55e2a4c232d3af0265b1d /test/image_harness.zig
parent6878e1c309172d624c0d7a3555f6f0217ae6770e (diff)
downloadpardes-682e237df7e8b22f820d14a4adee58e6e2f84268.tar.gz
pardes-682e237df7e8b22f820d14a4adee58e6e2f84268.zip
trunk: resume before the Reload experiment
Empty marker on the last pre-Reload change. Keep the Reload experiment on reload (3801914), its first change on reload-start (200a1fc), and the unfinished performance investigation on reload-perf-wip.
Diffstat (limited to 'test/image_harness.zig')
-rw-r--r--test/image_harness.zig49
1 files changed, 31 insertions, 18 deletions
diff --git a/test/image_harness.zig b/test/image_harness.zig
index 1141d81f..474ec48b 100644
--- a/test/image_harness.zig
+++ b/test/image_harness.zig
@@ -22,7 +22,7 @@ extern "c" fn unsetenv(name: [*:0]const u8) c_int;
const gpa = std.heap.page_allocator;
const fixture_rgb = [3]u8{ 13, 77, 231 };
-// The harness isolates configuration, so fresh PDFs use the boot `helix`
+// The harness pins configuration, so fresh PDFs use the legacy `helix`
// theme (#080808 paper, #bdbdbd ink). These are the exact fixed-point
// filtered-tint results for the fixture's saturated red and green pages.
const pdf_filtered_red = [3]u8{ 255, 77, 77 };
@@ -50,6 +50,10 @@ pub fn main(init: std.process.Init) !void {
// native process under test; this nonexistent directory is test-owned.
const config_home = try std.fmt.allocPrintSentinel(arena, "{s}/.config", .{base}, 0);
_ = setenv("XDG_CONFIG_HOME", config_home, 1);
+ if (libc.mkdir(config_home, 0o755) != 0) return error.MkdirFailed;
+ 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");
_ = setenv("HISTFILE", "/dev/null", 1);
_ = setenv("TERM", "xterm-256color", 1);
_ = setenv("LC_ALL", "C", 1);
@@ -68,6 +72,12 @@ pub fn main(init: std.process.Init) !void {
}
fn cleanupBase(arena: std.mem.Allocator, base: [:0]const u8) void {
+ const init_path = std.fmt.allocPrintSentinel(arena, "{s}/.config/pardes/init", .{base}, 0) catch return;
+ _ = libc.unlink(init_path);
+ const config_dir = std.fmt.allocPrintSentinel(arena, "{s}/.config/pardes", .{base}, 0) catch return;
+ _ = 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" };
for (names) |name| {
const path = std.fmt.allocPrintSentinel(arena, "{s}/{s}", .{ base, name }, 0) catch continue;
@@ -279,7 +289,8 @@ fn runKittyPdf(arena: std.mem.Allocator, exe: [:0]const u8, base: [:0]const u8)
try writePdf(arena, pdf_path, .red);
defer _ = libc.unlink(pdf_path);
- var h = try eh.Harness.initArgs(gpa, exe, 16, 40, pdf_path);
+ // Preserve fourteen document rows below workspace, column and pane tags.
+ var h = try eh.Harness.initArgs(gpa, exe, 17, 40, pdf_path);
defer h.deinit();
try h.expectRawWaitFor(
"\x1b_Gi=1,a=q\x1b\\",
@@ -292,15 +303,15 @@ fn runKittyPdf(arena: std.mem.Allocator, exe: [:0]const u8, base: [:0]const u8)
const first_deadline = eh.nowMs() + 5000;
while (eh.nowMs() < first_deadline) {
_ = try h.pumpOnce(50);
- const sent = std.mem.indexOf(u8, h.raw.items, transmit) != null;
+ const sent = std.mem.count(u8, h.raw.items, transmit) >= 2;
const placed = std.mem.indexOf(u8, h.raw.items, "\x1b_Ga=p,i=") != null;
- if (sent and placed and h.contains("pdf 1/4 width PdfFit filtered PdfTint")) break;
+ if (sent and placed and h.contains("[1/4]")) break;
}
try h.expectRawContains(transmit, "first PDF page was not transmitted as the 96x64 Kitty raster");
try h.expectRawContains("\x1b_Ga=p,i=", "first PDF page was not placed in the pane body");
try h.expectContains(
- "pdf 1/4 width PdfFit filtered PdfTint",
- "fresh PDF pane did not expose filtered tint as its default",
+ "[1/4]",
+ "fresh PDF pane did not show its compact page indicator",
);
// Fit-width is the initial PDF policy. The short fixture pages make the
@@ -334,7 +345,7 @@ fn runKittyPdf(arena: std.mem.Allocator, exe: [:0]const u8, base: [:0]const u8)
_ = try h.pumpOnce(50);
if (std.mem.count(u8, h.raw.items, transmit) != initial_transmits)
return error.KittyPdfPlacementScrollRetransmitted;
- try h.expectContains("pdf 1/4 width PdfFit", "one-row scroll snapped to another PDF page");
+ try h.expectContains("[1/4]", "one-row scroll snapped to another PDF page");
// The newly exposed page-two head is 29px tall and begins three pixels
// into a cell. Kitty infers an integer row count when only c is supplied;
@@ -364,7 +375,7 @@ fn runKittyPdf(arena: std.mem.Allocator, exe: [:0]const u8, base: [:0]const u8)
const transmits_before_step = std.mem.count(u8, h.raw.items, all_transmits);
const page_three_transmit = "\x1b_Gf=32,s=96,v=64,i=";
try h.send("\x06");
- try h.expectWaitFor("pdf 2/4 width PdfFit", 5000, "continuous page-down did not enter PDF page two");
+ try h.expectWaitFor("[2/4]", 5000, "continuous page-down did not enter PDF page two");
const page_step_deadline = eh.nowMs() + 5000;
while (eh.nowMs() < page_step_deadline and
std.mem.indexOf(u8, h.raw.items[page_step_start..], page_three_transmit) == null)
@@ -380,7 +391,7 @@ fn runKittyPdf(arena: std.mem.Allocator, exe: [:0]const u8, base: [:0]const u8)
// viewport, then submitting the bare search selects and Looks its first
// hit through the shared walk, creating a decorated page-two revision.
try h.send("\x02");
- try h.expectWaitFor("pdf 1/4 width PdfFit", 5000, "continuous page-up did not return to PDF page one");
+ try h.expectWaitFor("[1/4]", 5000, "continuous page-up did not return to PDF page one");
const transmits_before_search = std.mem.count(u8, h.raw.items, all_transmits);
try h.send("/SECOND\r");
const search_row = try std.fmt.allocPrint(arena, "{s}:2:1 SECOND", .{std.fs.path.basename(pdf_path)});
@@ -389,9 +400,9 @@ fn runKittyPdf(arena: std.mem.Allocator, exe: [:0]const u8, base: [:0]const u8)
while (eh.nowMs() < look_deadline) {
_ = try h.pumpOnce(50);
if (std.mem.count(u8, h.raw.items, all_transmits) > transmits_before_search and
- h.contains("pdf 2/4 width PdfFit")) break;
+ h.contains("[2/4]")) break;
}
- try h.expectContains("pdf 2/4 width PdfFit", "bare search did not reveal its first PDF hit at page two");
+ try h.expectContains("[2/4]", "bare search did not reveal its first PDF hit at page two");
if (std.mem.count(u8, h.raw.items, all_transmits) <= transmits_before_search)
return error.KittyPdfLookRetransmitMissing;
@@ -400,7 +411,7 @@ fn runKittyPdf(arena: std.mem.Allocator, exe: [:0]const u8, base: [:0]const u8)
const before_fit = std.mem.count(u8, h.raw.items, all_transmits);
const fit_raw_start = h.raw.items.len;
try h.send(" tz");
- try h.expectWaitFor("pdf 2/4 height PdfFit", 5000, "PdfFit did not expose height fit");
+ try h.expectWaitFor("[2/4]", 5000, "PdfFit did not expose height fit");
const fit_deadline = eh.nowMs() + 3000;
while (eh.nowMs() < fit_deadline and
kittyPlacementApcWithParam(h.raw.items, fit_raw_start, 'r') == null)
@@ -425,7 +436,7 @@ fn runKittyPdf(arena: std.mem.Allocator, exe: [:0]const u8, base: [:0]const u8)
const upper_start = h.raw.items.len;
try h.send("n\r");
- try h.expectWaitFor("pdf 1/4 height PdfFit", 5000, "first PdfSections n+Look did not reveal page one");
+ try h.expectWaitFor("[1/4]", 5000, "first PdfSections n+Look did not reveal page one");
const upper_deadline = eh.nowMs() + 3000;
while (eh.nowMs() < upper_deadline and kittyPlacementApc(h.raw.items, upper_start) == null)
_ = try h.pumpOnce(50);
@@ -437,7 +448,7 @@ fn runKittyPdf(arena: std.mem.Allocator, exe: [:0]const u8, base: [:0]const u8)
const lower_start = h.raw.items.len;
try h.send("n\r");
- try h.expectWaitFor("pdf 1/4 height PdfFit", 5000, "nested PdfSections n+Look left page one");
+ try h.expectWaitFor("[1/4]", 5000, "nested PdfSections n+Look left page one");
const lower_deadline = eh.nowMs() + 3000;
while (eh.nowMs() < lower_deadline and kittyPlacementApc(h.raw.items, lower_start) == null)
_ = try h.pumpOnce(50);
@@ -449,9 +460,9 @@ fn runKittyPdf(arena: std.mem.Allocator, exe: [:0]const u8, base: [:0]const u8)
return error.KittyPdfSectionsSamePageRetransmitted;
try h.send("n\r");
- try h.expectWaitFor("pdf 2/4 height PdfFit", 5000, "third PdfSections n+Look did not reveal page two");
+ try h.expectWaitFor("[2/4]", 5000, "third PdfSections n+Look did not reveal page two");
try h.send("N\r");
- try h.expectWaitFor("pdf 1/4 height PdfFit", 5000, "PdfSections N+Look did not return to the nested page-one row");
+ try h.expectWaitFor("[1/4]", 5000, "PdfSections N+Look did not return to the nested page-one row");
// Editor-style save: build a same-sized blue first page on another inode,
// atomically rename it over the live pathname, and send NO input. The
@@ -548,9 +559,11 @@ fn runGuiPdf(arena: std.mem.Allocator, exe: [:0]const u8, base: [:0]const u8) !v
_ = setenv("PARDES_TEST", "1", 1);
_ = setenv("PARDES_TEST_CAPTURE_DIR", base, 1);
_ = setenv("PARDES_TEST_COLS", "20", 1);
- _ = setenv("PARDES_TEST_ROWS", "10", 1);
+ // Keep eight document rows beneath the workspace, column and pane tags;
+ // the fit-height assertions below compare this viewport with width-fit.
+ _ = setenv("PARDES_TEST_ROWS", "11", 1);
- var h = try eh.Harness.initArgs(gpa, exe, 10, 20, pdf_path);
+ var h = try eh.Harness.initArgs(gpa, exe, 11, 20, pdf_path);
defer h.deinit();
const fit_width = try waitForCaptureBounds(&h, capture_path, pdf_filtered_red, 500, 5000);
const initial_green = try waitForCaptureBounds(&h, capture_path, pdf_filtered_green, 500, 5000);