From f7442cb1f23ce10ccedaa37b1851d751f689943d Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 19:19:26 -0300 Subject: test: the process tests run on each backend (the user: an effect's test is its backend's): zig build process-test -Dplatform=tty drives pardes, -Dplatform=gui drives pardes-gui hidden (PARDES_TEST, SDL_VIDEO_DRIVER=offscreen, no display of the user's touched) on a pty of its own and a detached session's 160x50 grid, its frames and status in a capture directory of its own, Detached.frame() waiting for it to say it is idle; the runner told its backend (--backend, from the build), each line marked [tty] or [gui] with its time, a case that skips said so; the terminal frontend's and a detached session's own cases (pardes -, a killed tty editor, a signalled detached session, a message expiring with nothing attached) process.only(.tty), a detached session's size checks and pty pixel cells the tty's alone; the canary tty-only for now (on the window its Newcol is refused after the terminal steps, docs/next-tests.md); tty 36 of 36, gui 31 and 5 skipped Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/process_test.zig | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'test/process_test.zig') diff --git a/test/process_test.zig b/test/process_test.zig index 2f1b5791..a870f13a 100644 --- a/test/process_test.zig +++ b/test/process_test.zig @@ -4,6 +4,7 @@ //! //! pardes-process-test [filter] const std = @import("std"); +const process = @import("process.zig"); const files = .{ @import("process/builtins.zig"), @@ -19,25 +20,42 @@ const files = .{ }; pub fn main(init: std.process.Init) !void { - const args = try init.minimal.args.toSlice(init.arena.allocator()); - if (args.len < 2) return error.Usage; - const exe = args[1]; - const filter: []const u8 = if (args.len > 2) args[2] else ""; + const all = try init.minimal.args.toSlice(init.arena.allocator()); + // [--backend=tty|gui] [filter] + var args: [3][:0]const u8 = undefined; + var n: usize = 0; + for (all[1..]) |a| { + if (std.mem.startsWith(u8, a, "--backend=")) { + process.backend = std.meta.stringToEnum(process.Backend, a["--backend=".len..]) orelse return error.Usage; + } else if (n < args.len) { + args[n] = a; + n += 1; + } + } + if (n < 1) return error.Usage; + const exe = args[0]; + const filter: []const u8 = if (n > 1) args[1] else ""; const gpa = std.heap.page_allocator; + const on = @tagName(process.backend); var failed: usize = 0; + var skipped: usize = 0; var ran: usize = 0; inline for (files) |file| inline for (file.cases) |case| { if (std.mem.indexOf(u8, case[0], filter) != null) { ran += 1; + const t0 = process.nowMs(); if (case[1](gpa, exe)) { - std.debug.print("PASS {s}\n", .{case[0]}); - } else |err| { + std.debug.print("PASS [{s}] {d} ms {s}\n", .{ on, process.nowMs() - t0, case[0] }); + } else |err| if (err == error.SkipZigTest) { + skipped += 1; + std.debug.print("SKIP [{s}] {s}\n", .{ on, case[0] }); + } else { failed += 1; if (@errorReturnTrace()) |t| std.debug.dumpErrorReturnTrace(t); - std.debug.print("FAIL {s}: {t}\n", .{ case[0], err }); + std.debug.print("FAIL [{s}] {d} ms {s}: {t}\n", .{ on, process.nowMs() - t0, case[0], err }); } } }; - std.debug.print("{d} of {d} process tests failed\n", .{ failed, ran }); + std.debug.print("{d} of {d} process tests failed on {s} ({d} skipped)\n", .{ failed, ran, on, skipped }); if (failed > 0 or ran == 0) std.process.exit(1); } -- cgit v1.3