summaryrefslogtreecommitdiff
path: root/tests.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-07-03 17:33:05 -0300
committerGabriel Schneider <[email protected]>2026-08-01 15:02:07 -0300
commitf3b62fe53b19e36f21f8020831718cbf095d6a7b (patch)
treecdfd008869bb5f5aeb69f0ef30584fec86f6f95b /tests.zig
parent6b4b1f76bb6bf969fb5106f95fb3f9ad077fac08 (diff)
downloadpardes-f3b62fe53b19e36f21f8020831718cbf095d6a7b.tar.gz
pardes-f3b62fe53b19e36f21f8020831718cbf095d6a7b.zip
performance pass
Diffstat (limited to 'tests.zig')
-rw-r--r--tests.zig48
1 files changed, 32 insertions, 16 deletions
diff --git a/tests.zig b/tests.zig
index ebcc12df..6080aa3b 100644
--- a/tests.zig
+++ b/tests.zig
@@ -4,6 +4,8 @@ const Harness = h.Harness;
const config = @import("config");
const dump = @import("dump.zig");
+const ls_ready = "tests.zig";
+
// E2E tests for pardes. The harness forks the app in a pty and parses its
// output with a ghostty terminal emulator, so all assertions read the 2D screen
// GRID (plainString) — not raw byte streams. This is decoupled from the app's
@@ -37,6 +39,17 @@ fn colOf(text: []const u8, needle: []const u8) ?usize {
return null;
}
+fn clearRightColumnTerminal(hs: *Harness) !void {
+ try hs.send("\x1b[<0;60;20M\x1b[<0;60;20m"); // focus the right-column terminal
+ try hs.pump(300);
+ try hs.send("\x02"); // normal -> tty
+ try hs.pump(400);
+ try hs.send("clear\r");
+ try hs.pump(800);
+ try hs.send("\x02"); // tty -> normal
+ try hs.pump(400);
+}
+
fn writeReplayFixture(io: std.Io, gpa: std.mem.Allocator, path: []const u8) !void {
const file_content =
"const std = @import(\"std\");\n" ++
@@ -191,7 +204,7 @@ pub fn main(init: std.process.Init) !void {
// the resize counter to 1 and repaints, so "resizes=1" shows in the debug
// overlay. Confirms the app is up and handled its first size.
try hs.expectWaitFor("resizes=1", 6000, "app never handled its initial winsize (no 'resizes=1')");
- try hs.expectWaitFor("build.zig", 8000, "new terminals did not auto-ls their directory on open");
+ try hs.expectWaitFor(ls_ready, 8000, "new terminals did not auto-ls their directory on open");
// 1b. Dump is a global-tagbar builtin. It writes a backend-independent ZON
// snapshot with compact pane ids, layout columns, rendered pane text, and
@@ -227,7 +240,7 @@ pub fn main(init: std.process.Init) !void {
}
const tty_bytes = try dump.decodeBytes(gpa, dumped.panes[0].terminal.?.stream_b64);
defer gpa.free(tty_bytes);
- if (std.mem.indexOf(u8, tty_bytes, "build.zig") == null) {
+ if (std.mem.indexOf(u8, tty_bytes, ls_ready) == null) {
hs.dump("Dump terminal byte stream does not replay the visible ls output");
return error.ExpectFailed;
}
@@ -238,7 +251,7 @@ pub fn main(init: std.process.Init) !void {
defer replay_h.deinit();
try replay_h.pump(1200);
try replay_h.expectContains("Kill Newcol", "replay did not render the dump topbar");
- try replay_h.expectContains("build.zig", "replay did not rebuild the terminal from the dumped byte stream");
+ try replay_h.expectContains(ls_ready, "replay did not rebuild the terminal from the dumped byte stream");
try replay_h.expectNotContains("\xc2\xaa", "replay rendered corrupt prefix bytes");
}
{
@@ -307,7 +320,7 @@ pub fn main(init: std.process.Init) !void {
// 3b. ls-on-open: a fresh shell greets with its directory listing. The e2e app
// boots in the project dir, so a known file shows up as command output
// (visible even in normal mode — only prompt rows are hidden).
- try hs.expectWaitFor("build.zig", 8000, "new terminals did not auto-ls their directory on open");
+ try hs.expectWaitFor(ls_ready, 8000, "new terminals did not auto-ls their directory on open");
// 3c. Normal-mode TAB = acme middle-click "execute" the word under the cursor.
// Drop a one-line executable, echo its path onto body row 0 (clear homes the
@@ -518,6 +531,7 @@ pub fn main(init: std.process.Init) !void {
}
try hs.resize(30, 100); // clean geometry (right column starts ~col 51)
try hs.pump(700); // settle the reflow
+ try clearRightColumnTerminal(&hs);
try hs.send("\x1b[<0;60;26M\x1b[<0;60;26m"); // left-click a blank row well below the ls output, right column -> normal + pin (+1 row: global tagbar)
try hs.pump(400);
try hs.send("i"); // normal -> insert so typing composes the path:line
@@ -615,9 +629,10 @@ pub fn main(init: std.process.Init) !void {
hs_save.trace = config.trace;
defer hs_save.deinit();
try h.writeFile("/tmp/pardesE2Esave.txt", "ZZORIG_SAVE_SHOULD_DISAPPEAR_AND_TAIL\n");
- try hs_save.expectWaitFor("build.zig", 8000, "save regression app never auto-ls'd");
+ try hs_save.expectWaitFor(ls_ready, 8000, "save regression app never auto-ls'd");
try hs_save.resize(30, 100);
try hs_save.pump(700);
+ try clearRightColumnTerminal(&hs_save);
try hs_save.send("\x1b[<0;60;20M\x1b[<0;60;20m"); // pin a blank row, right column -> normal
try hs_save.pump(400);
try hs_save.send("i");
@@ -705,7 +720,7 @@ pub fn main(init: std.process.Init) !void {
{
var hs3 = try Harness.init(gpa, exe.ptr, 24, 80);
defer hs3.deinit();
- try hs3.expectWaitFor("build.zig", 8000, "fresh terminal never auto-ls'd");
+ try hs3.expectWaitFor(ls_ready, 8000, "fresh terminal never auto-ls'd");
// pin the cursor on the top-left pane and type a marker (insert mode).
try hs3.send("\x1b[<0;5;8M\x1b[<0;5;8m"); // left-click -> normal + pin (+1 row: global tagbar)
try hs3.pump(400);
@@ -743,7 +758,7 @@ pub fn main(init: std.process.Init) !void {
{
var hs4 = try Harness.init(gpa, exe.ptr, 24, 80);
defer hs4.deinit();
- try hs4.expectWaitFor("build.zig", 8000, "fresh terminal never auto-ls'd");
+ try hs4.expectWaitFor(ls_ready, 8000, "fresh terminal never auto-ls'd");
try hs4.send("\x02"); // normal -> tty
try hs4.pump(500);
try hs4.send("clear\r"); // blank the pane, prompt to row 0
@@ -771,7 +786,7 @@ pub fn main(init: std.process.Init) !void {
{
var hs5 = try Harness.init(gpa, exe.ptr, 24, 80);
defer hs5.deinit();
- try hs5.expectWaitFor("build.zig", 8000, "fresh terminal never auto-ls'd");
+ try hs5.expectWaitFor(ls_ready, 8000, "fresh terminal never auto-ls'd");
{
var ppm: std.ArrayList(u8) = .empty;
defer ppm.deinit(gpa);
@@ -815,11 +830,12 @@ pub fn main(init: std.process.Init) !void {
{
var hs6 = try Harness.init(gpa, exe.ptr, 24, 80);
defer hs6.deinit();
- try hs6.expectWaitFor("build.zig", 8000, "fresh terminal never auto-ls'd");
+ try hs6.expectWaitFor(ls_ready, 8000, "fresh terminal never auto-ls'd");
try h.writeFile("/tmp/pardesE2Efa.txt", "ZZFILEA\nfa1\nfa2\nfa3\nfa4\nfa5\nfa6\nfa7\nfa8\nfa9\n");
try h.writeFile("/tmp/pardesE2Efb.txt", "ZZFILEB\nfb1\nfb2\nfb3\nfb4\nfb5\nfb6\nfb7\nfb8\nfb9\n");
try hs6.resize(30, 100); // clean geometry: right column starts ~col 51
try hs6.pump(700);
+ try clearRightColumnTerminal(&hs6);
// open file A from the right-column terminal: the FIRST doc pane, so it
// takes the stack-at-top fallback (no existing doc pane to split).
try hs6.send("\x1b[<0;60;20M\x1b[<0;60;20m"); // pin a blank row, right column -> normal
@@ -865,7 +881,7 @@ pub fn main(init: std.process.Init) !void {
{
var hs7 = try Harness.init(gpa, exe.ptr, 24, 80);
defer hs7.deinit();
- try hs7.expectWaitFor("build.zig", 8000, "fresh terminal never auto-ls'd");
+ try hs7.expectWaitFor(ls_ready, 8000, "fresh terminal never auto-ls'd");
try hs7.resize(30, 120); // 3 columns of ~40 each
try hs7.pump(700);
// add a 3rd column via the global-tagbar "Newcol" (cols 5-10, 0-based).
@@ -917,7 +933,7 @@ pub fn main(init: std.process.Init) !void {
{
var hs8 = try Harness.init(gpa, exe.ptr, 24, 80);
defer hs8.deinit();
- try hs8.expectWaitFor("build.zig", 8000, "fresh terminal never auto-ls'd");
+ try hs8.expectWaitFor(ls_ready, 8000, "fresh terminal never auto-ls'd");
try hs8.send("\x02"); // normal -> tty
try hs8.pump(600);
// -icanon so the reply's bytes reach `read` without a newline; read until the
@@ -938,7 +954,7 @@ pub fn main(init: std.process.Init) !void {
{
var hs9 = try Harness.init(gpa, exe.ptr, 24, 80);
defer hs9.deinit();
- try hs9.expectWaitFor("build.zig", 8000, "fresh terminal never auto-ls'd");
+ try hs9.expectWaitFor(ls_ready, 8000, "fresh terminal never auto-ls'd");
try hs9.send("\x02"); // normal -> tty
try hs9.pump(600);
// read until 'c' (primary DA ends in 'c'); the kitty reply ESC[?0u has no 'c',
@@ -957,7 +973,7 @@ pub fn main(init: std.process.Init) !void {
{
var hsc = try Harness.init(gpa, exe.ptr, 24, 80);
defer hsc.deinit();
- try hsc.expectWaitFor("build.zig", 8000, "chord test: fresh terminal never auto-ls'd");
+ try hsc.expectWaitFor(ls_ready, 8000, "chord test: fresh terminal never auto-ls'd");
try h.writeFile("/tmp/pardesE2Echord.sh", "#!/bin/sh\necho CHORDARG:\"$1\"\n");
try hsc.send("\x02"); // normal -> tty
try hsc.pump(500);
@@ -980,7 +996,7 @@ pub fn main(init: std.process.Init) !void {
{
var hscl = try Harness.init(gpa, exe.ptr, 24, 80);
defer hscl.deinit();
- try hscl.expectWaitFor("build.zig", 8000, "clear test: fresh terminal never auto-ls'd");
+ try hscl.expectWaitFor(ls_ready, 8000, "clear test: fresh terminal never auto-ls'd");
try h.writeFile("/tmp/pardesE2Echord.sh", "#!/bin/sh\necho CHORDARG:\"$1\"\n");
try hscl.send("\x02");
try hscl.pump(500);
@@ -1005,7 +1021,7 @@ pub fn main(init: std.process.Init) !void {
{
var hsr = try Harness.init(gpa, exe.ptr, 24, 80);
defer hsr.deinit();
- try hsr.expectWaitFor("build.zig", 8000, "replace test: fresh terminal never auto-ls'd");
+ try hsr.expectWaitFor(ls_ready, 8000, "replace test: fresh terminal never auto-ls'd");
try h.writeFile("/tmp/pardesE2Echord.sh", "#!/bin/sh\necho CHORDARG:\"$1\"\n");
try hsr.send("\x02");
try hsr.pump(500);
@@ -1029,7 +1045,7 @@ pub fn main(init: std.process.Init) !void {
{
var hsb = try Harness.init(gpa, exe.ptr, 24, 80);
defer hsb.deinit();
- try hsb.expectWaitFor("build.zig", 8000, "builtin-chord test: fresh terminal never auto-ls'd");
+ try hsb.expectWaitFor(ls_ready, 8000, "builtin-chord test: fresh terminal never auto-ls'd");
try hsb.send("\x02");
try hsb.pump(500);
try hsb.send("clear; printf 'ZZBUILTARG\\nDebug\\n'\r");