From 6ff5fc7447cc411dc24cb1d841130f15a410e354 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 3 Nov 2026 17:08:35 -0300 Subject: test: three of test/output.zig's tests through the 9P tree alone: DumpConfig's report in its one +DumpConfig pane, a second refreshing it in place (settings, a new file: /index, /focus and its body, Theme acme seen there), Config with no configuration directory refused, said in the log and opening nothing (settings), a Mini that cannot read its file leaving the panes, the last snapshot and the keyboard as they were (panes); the startup path line stays, a process flag with no 9P surface; each checked to fail against a break (openRead never reusing an output pane, Config taking a made-up path when there is no directory, a failed Mini giving the keyboard back to its caller) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/behaviour/settings.zig | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 test/behaviour/settings.zig (limited to 'test/behaviour/settings.zig') diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig new file mode 100644 index 00000000..57751ab1 --- /dev/null +++ b/test/behaviour/settings.zig @@ -0,0 +1,38 @@ +//! docs/typ/reference.typ, Settings . +const std = @import("std"); +const Session = @import("session").Session; + +fn has(text: []const u8, part: []const u8) !void { + if (std.mem.indexOf(u8, text, part) == null) { + std.debug.print("not in it: {s}\n", .{part}); + return error.TestExpectedText; + } +} + +test "settings: DumpConfig reports the settings in its one +DumpConfig pane, a second refreshing it" { + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + const text = try s.focused(); + const exec = s.at("/pane/{d}/exec", .{text}); + try s.write(exec, "DumpConfig\n"); + const out = try s.focused(); + try std.testing.expect(out != text); + try std.testing.expect(std.mem.indexOf(u8, try s.read("/index"), s.at("{d} text 0 /+DumpConfig ", .{out})) != null); + const report = try s.read(s.at("/pane/{d}/body", .{out})); + for ([_][]const u8{ "Theme orchard\n", "Last shell spawned: (none)\n", "Shell change pending: on\n", "\nShell ", "LocationsConfig ", "no per-user config path" }) |line| try has(report, line); + try s.write("/ctl", "Theme acme\n"); + try s.write("/focus", s.at("{d}", .{text})); + try s.write(exec, "DumpConfig\n"); + try std.testing.expectEqual(out, try s.focused()); + try std.testing.expectEqual(@as(usize, 1), std.mem.count(u8, try s.read("/index"), "/+DumpConfig ")); + try has(try s.read(s.at("/pane/{d}/body", .{out})), "Theme acme\n"); +} + +test "settings: Config without a configuration directory says so and opens nothing" { + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + const index = try s.read("/index"); + try std.testing.expectEqual(@as(u16, 5), try s.refused(s.at("/pane/{d}/exec", .{try s.focused()}), "Config\n")); + try s.expect("/index", index); + try has(try s.read("/log"), "Config: no startup file here: no configuration directory"); +} -- cgit v1.3