summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/behaviour/settings.zig63
-rw-r--r--test/session.zig11
2 files changed, 74 insertions, 0 deletions
diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig
index 25a3bc04..66cd97df 100644
--- a/test/behaviour/settings.zig
+++ b/test/behaviour/settings.zig
@@ -271,3 +271,66 @@ test "settings: a keyword is coloured apart from the text beside it, and not bol
try std.testing.expect(!std.mem.eql(u8, ink, plain));
}
}
+
+test "settings: the user's startup file loads clean, every word of it known and its value read back" {
+ // ~/.config/pardes/init as it was on 2026-11-05, copied, never read.
+ const init =
+ \\Theme monokai_pro_classic
+ \\# Theme catppuccin_macchiato
+ \\# Theme orchard
+ \\# Theme solarium
+ \\# Theme spectrum
+ \\# Theme doom_one
+ \\GripWidth 110
+ \\CallstackDepth 64
+ \\InactiveDim 5
+ \\Shell fish
+ \\CursorBlink off
+ \\JumpTrail on
+ \\WindowOpacity 100
+ \\Font Go-Mono:18
+ \\# Font JetBrainsMono-Medium:18
+ \\TaglineSize 80
+ \\LocationsConfig context:4 tscontext:on tslocations:on layout:stacked
+ \\
+ \\# Theme neobones_dark
+ \\# Font PaperMono-Regular
+ \\# Font B612Mono-Regular
+ \\# Font Go-Mono
+ \\# Font Hermit-Regular
+ \\# Font IBMPlexMono-Medium
+ \\# Font InputMono-Regular
+ \\# Font InputMonoNarrow-Regular
+ \\# Font JetBrainsMono-Regular
+ \\# Font JuliaMono-Regular
+ \\# Font FantasqueSansMono-Regular
+ \\# Font MartianMono-NrRg:16
+ \\Pet frog
+ \\
+ ;
+ var s = try Session.initStartup(std.testing.allocator, init);
+ defer s.deinit();
+ try std.testing.expect(!has(try s.read("/log"), "init file line"));
+ const ctl = try s.read("/ctl");
+ for ([_][]const u8{ "Theme monokai_pro_classic\n", "CallstackDepth 64\n", "InactiveDim 5\n", "Shell fish\n", "JumpTrail on\n", "LocationsConfig context:4 tscontext:on tslocations:on layout:stacked\n" }) |line| try expectHas(ctl, line);
+ // The window's words, which a terminal's view leaves to the window.
+ const window = @import("pardes_config").platform == .gui;
+ for ([_][2][]const u8{ .{ "GripWidth", "110" }, .{ "CursorBlink", "off" }, .{ "WindowOpacity", "100" }, .{ "TaglineSize", "80" }, .{ "Pet", "frog" } }) |w|
+ try expectHas(ctl, if (window) s.at("\n{s} {s}\n", .{ w[0], w[1] }) else s.at("\n# {s} unsupported\n", .{w[0]}));
+}
+
+test "settings: a word cut from the settings is an unknown word: the root ctl refuses it, /commands has it not, and a startup file saying it gets a notice" {
+ const cut = [_][]const u8{ "Colors", "TreeContextTagStyle", "Tagbottom", "FocusTint", "SyntaxBold", "Ligatures", "Pager", "PagerColor", "TermImages", "SearchPlace", "SearchPane", "SearchRows", "ProgramEsc", "JumpScope", "WindowBlur" };
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const commands = try s.read("/commands");
+ for (cut) |word| {
+ try std.testing.expectEqual(@as(u16, 22), try s.refused("/ctl", s.at("{s} on\n", .{word})));
+ try std.testing.expectEqualStrings(s.at("unknown control message \"{s}\"", .{word}), s.said);
+ try std.testing.expect(!std.mem.startsWith(u8, commands, s.at("{s} ", .{word})) and !has(commands, s.at("\n{s} ", .{word})));
+ }
+ var t = try Session.initStartup(std.testing.allocator, "Tagbottom on\nWrap off\n");
+ defer t.deinit();
+ try expectHas(try t.read("/log"), "init file line 1: unknown word \"Tagbottom on\"");
+ try std.testing.expect(std.mem.startsWith(u8, try t.read("/ctl"), "Wrap off\n"));
+}
diff --git a/test/session.zig b/test/session.zig
index 71627dad..c3e6c579 100644
--- a/test/session.zig
+++ b/test/session.zig
@@ -47,6 +47,17 @@ pub const Session = struct {
return s;
}
+ /// A session showing one file pane, its startup file `init` (as
+ /// `~/.config/pardes/init` is read) applied first.
+ pub fn initStartup(gpa: std.mem.Allocator, init: []const u8) !Session {
+ const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24, .state = .memory, .startup_config = init });
+ errdefer p.deinit();
+ _ = try p.setTestFile("x\n");
+ var s: Session = .{ .core = p, .arena = .init(gpa) };
+ s.drain();
+ return s;
+ }
+
/// A session showing its terminal pane, as `pardes` starts.
pub fn initTerm(gpa: std.mem.Allocator) !Session {
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24, .state = .memory });