From 6bcb18e021a09d51539e628106a594748637ead2 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 16:46:18 -0300 Subject: test: fs.py's inline checks, quic_test, workflow_canary, python_repl_runs_one_line and signal_cleans_up moved to Zig, deleted from fs.py (its named cases stay): 21 process cases in test/process/ (flags: bad options refused in words, --9p naming the socket, forwarding a launch inside a session and the launches that start their own (mount, name, tcp, load, shells, toggle, quic), --wait and its refusals, pardes - and its +Pager (escapes, inks and Filter, progress, 11 MiB, the 256 MiB cut), $winid, the stdin boot, no terminal to draw on, a killed tty editor and its swept sockets, a signal unlinking the socket; mounts: --mount at startup, Mount and Unmount at run time, QUIC and TCP v4 and v6 detached and in a pty (skipped without -Dquic=true, passed with it); tree: the root and /os, 256-byte frames, a held ctl line, a frozen /screen, Look's precedence, 255-byte names; root-ctl: Restore detached and in a pty; builtins: Lspinfo; look-and-exec: the canary; repls: Python's pyrepl) and 3 behaviour tests (a 60 KB body write, truncated, a missing pane refused; a body write's EI record; keyword colour, not bold); process.zig gains, under fsb:, Conn.dialSized, dialTcp, replace, newPane, serials, look, pane, exec, execRefused, removePane, Files.fg, Detached.exists, abs, startTty, and Child (a program in a root's environment, its stdin fed, on a pty if asked, its stderr kept), run, code, entries, canonical, quicIncluded, nowMs, nap, has, check; each checked to fail against a break (no such option reworded, SyntaxBold on by default, a body insert's record not EI, Grep's miss reworded, already inside pardes reworded, a session already running reworded, Lspinfo's servers line reworded, no terminal to draw on reworded, unknown control message reworded); behaviour, process, fs-unit and core tests and the rest of fs.py pass Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/process/builtins.zig | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 test/process/builtins.zig (limited to 'test/process/builtins.zig') diff --git a/test/process/builtins.zig b/test/process/builtins.zig new file mode 100644 index 00000000..39a043c0 --- /dev/null +++ b/test/process/builtins.zig @@ -0,0 +1,52 @@ +//! docs/typ/reference.typ, Builtins a real session runs, detached +//! and in a pty. +const std = @import("std"); +const process = @import("../process.zig"); +const Conn = process.Conn; +const has = process.has; +const check = process.check; + +pub const cases = .{ + .{ "builtins: Lspinfo opens one +Lsp pane saying the backend and its servers, detached and in a pty", lspinfo }, +}; + +fn lspinfo(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + for ([_]bool{ false, true }) |tty| { + var arena = std.heap.ArenaAllocator.init(gpa); + defer arena.deinit(); + const a = arena.allocator(); + const name = if (tty) "lsp-tty" else "lsp-detached"; + var d = try process.Detached.start(gpa, exe, if (tty) "lsp-root" else name, .{}); + defer d.deinit(); + var term: ?process.Child = null; + defer if (term) |*t| t.deinit(); + if (tty) term = try d.startTty(exe, name, &.{}); + const address = d.abs(try std.fmt.allocPrint(a, "pardes-9p-{s}.sock", .{name})); + const c = try Conn.dial(gpa, address); + defer c.deinit(gpa); + const control = try c.newPane(a); + try c.exec(control, "Lspinfo\n"); + const deadline = process.nowMs() + 3_000; + const lsp = while (true) { + var found: ?u32 = null; + var count: usize = 0; + var rows = std.mem.tokenizeScalar(u8, try c.read(a, "/index"), '\n'); + while (rows.next()) |row| if (has(row, "+Lsp")) { + count += 1; + found = try std.fmt.parseInt(u32, row[0..std.mem.indexOfScalar(u8, row, ' ').?], 10); + }; + if (found) |n| { + try check(count == 1, "{s}: {d} +Lsp panes", .{ name, count }); + break n; + } + if (process.nowMs() > deadline) return error.LspinfoNeverDone; + process.nap(5); + }; + const body = try c.pane(a, lsp, "body"); + try check(std.mem.startsWith(u8, body, "backend: lsp-client\n") and has(body, "protocol servers (lsp-client):"), "{s}", .{body}); + try std.testing.expectEqualStrings("initial\n", try c.read(a, "/pane/1/body")); + var f: process.Files = .init(gpa, address); + defer f.deinit(); + try check(has(try f.screen(), "+Lsp"), "+Lsp not drawn", .{}); + } +} -- cgit v1.3