summaryrefslogtreecommitdiff
path: root/src/config.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 00:01:13 -0300
committerGabriel Schneider <[email protected]>2026-11-05 00:09:51 -0300
commit43a4c24e607a456d7a23eb8a779bce5651f18222 (patch)
tree9525ea84d0b03a50fb4d26518b87854d4972398a /src/config.zig
parent90ed7135c7367a97131cfcc23cd61f905c5f4a47 (diff)
downloadpardes-43a4c24e607a456d7a23eb8a779bce5651f18222.tar.gz
pardes-43a4c24e607a456d7a23eb8a779bce5651f18222.zip
config: the DumpConfig report's unit test keeps what test/behaviour/settings.zig does not read through the root ctl and the +DumpConfig pane (now "DumpConfig report says each value setting as it was set, the font and the live context, and what a shell lacks as a comment"): each value setting from one table of word and value, where two switches over every action spelled each line, the font and context lines, the comments for what a terminal or the web lacks and the report's two halves; the switches, Theme, Shell and its lines, and the enabled asserts the unsupported lines already make go
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/config.zig')
-rw-r--r--src/config.zig174
1 files changed, 24 insertions, 150 deletions
diff --git a/src/config.zig b/src/config.zig
index 976c8a3d..0e469c28 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -1771,7 +1771,10 @@ pub const Runtime = struct {
try std.testing.expect(FontSpec.parse(bad) == null);
}
- test "DumpConfig report observes every simple setting and all live context" {
+ test "DumpConfig report says each value setting as it was set, the font and the live context, and what a shell lacks as a comment" {
+ // The switches, Theme, Shell, Pager and the shell's own lines are
+ // test/behaviour/settings.zig's, read through the root ctl and the
+ // +DumpConfig pane.
var state: Runtime = .{};
// Every setting, every context line: the report outgrows 4K.
var storage: [8192]u8 = undefined;
@@ -1794,130 +1797,17 @@ pub const Runtime = struct {
},
.state = &state,
};
-
- for (settings) |setting| {
- switch (setting.action) {
- .theme, .font => continue,
- else => {},
- }
- const argument: ?[]const u8 = switch (setting.action) {
- .shell => "fish",
- .tagline_size => "73",
- .window_opacity => "85",
- .window_blur => "40",
- .message_ms => "1500",
- .dump_dir => "~/dumps",
- .shader => "~/crt.glsl",
- .shader_animation => "always",
- .choice => |which| switch (which) {
- .placement => "pardes",
- .boot_shell => "replace",
- .look_word => "list",
- .dir_look => "terminal",
- .diff_look => "text",
- .pager => "off",
- .term_images => "petscii",
- .jump_scope => "all",
- .callstack_layout => "inline",
- .callstack_corners => "square",
- .search_place => "column",
- .search_pane => "new",
- },
- .lift => "rim",
- .motion => "playful",
- .inactive_dim => "35",
- .grip_width => "200",
- .callstack_depth => "16",
- .tab => "8",
- .search_rows => "12",
- else => null,
- };
- try std.testing.expect(apply(&state, setting, argument));
-
- var out: std.Io.Writer = .fixed(&storage);
- try writeReport(&out, context);
- const report = storage[0..out.end];
- const expected = switch (setting.action) {
- .toggle => |field| switch (field) {
- .colors => "Colors off\n",
- .wrap => "Wrap off\n",
- .tree_context_tag_style => "TreeContextTagStyle off\n",
- .tag_bottom => "Tagbottom on\n",
- .debug => "Debug on\n",
- .focus_tint => "FocusTint off\n",
- .syntax_bold => "SyntaxBold on\n",
- .pager_color => "PagerColor off\n",
- .verbose => "Verbose off\n",
- .message_animation => "MessageAnimation off\n",
- .ligatures => "Ligatures off\n",
- .cursor_blink => "CursorBlink off\n",
- .selection_glow => "SelectionGlow on\n",
- .hover_glow => "HoverGlow on\n",
- .occlusion => "Occlusion on\n",
- .parallax => "Parallax on\n",
- .jump_trail => "JumpTrail on\n",
- .chip_shadow => "ChipShadow on\n",
- .thumb_flash => "ThumbFlash on\n",
- .program_esc => "ProgramEsc on\n",
- },
- .shell => "Shell fish\n",
- .tagline_size => "TaglineSize 73\n",
- .window_opacity => "WindowOpacity 85\n",
- .window_blur => "WindowBlur 40\n",
- .dump_dir => "DumpDir ~/dumps\n",
- .message_ms => |which| switch (which) {
- .linger => "MessageLinger 1500\n",
- .fall => "MessageFall 1500\n",
- .dissolve => "MessageDissolve 1500\n",
- },
- .transition => |transition| switch (transition) {
- .off => unreachable,
- .slide => "PanelSlide on\n",
- .zoom => "PanelZoom on\n",
- .dissolve => "PanelDissolve on\n",
- .ascii => "PanelAscii on\n",
- .vertical => "PanelVertical on\n",
- .edges => "PanelEdges on\n",
- .fall => "PanelFall on\n",
- .wave => "PanelWave on\n",
- .curtain => "PanelCurtain on\n",
- .scramble => "PanelScramble on\n",
- .typewriter => "PanelType on\n",
- },
- .scene => |effect| switch (effect) {
- .crt => "Crt 2\n",
- .bloom => "Bloom 2\n",
- .vignette => "Vignette 2\n",
- .grain => "Grain 2\n",
- },
- .shader => "Shader ~/crt.glsl\n",
- .shader_animation => "ShaderAnimation always\n",
- .choice => |which| switch (which) {
- .placement => "Placement pardes\n",
- .boot_shell => "BootShell replace\n",
- .look_word => "LookWord list\n",
- .dir_look => "DirLook terminal\n",
- .diff_look => "DiffLook text\n",
- .pager => "Pager off\n",
- .term_images => "TermImages petscii\n",
- .jump_scope => "JumpScope all\n",
- .callstack_layout => "CallstackLayout inline\n",
- .callstack_corners => "CallstackCorners square\n",
- .search_place => "SearchPlace column\n",
- .search_pane => "SearchPane new\n",
- },
- .lift => "Lift rim\n",
- .motion => "Motion playful\n",
- .inactive_dim => "InactiveDim 35\n",
- .grip_width => "GripWidth 200\n",
- .callstack_depth => "CallstackDepth 16\n",
- .tab => "Tab 8\n",
- .search_rows => "SearchRows 12\n",
- .theme, .font => unreachable,
- };
- try std.testing.expect(std.mem.indexOf(u8, report, expected) != null);
- }
-
+ const values = [_][2][]const u8{
+ .{ "TaglineSize", "73" }, .{ "WindowOpacity", "85" }, .{ "WindowBlur", "40" },
+ .{ "MessageLinger", "1500" }, .{ "MessageFall", "1500" }, .{ "MessageDissolve", "1500" },
+ .{ "DumpDir", "~/dumps" }, .{ "Crt", "3" }, .{ "Shader", "~/crt.glsl" },
+ .{ "ShaderAnimation", "always" }, .{ "TermImages", "petscii" }, .{ "JumpScope", "all" },
+ .{ "CallstackLayout", "inline" }, .{ "CallstackCorners", "square" }, .{ "SearchPlace", "column" },
+ .{ "SearchPane", "new" }, .{ "Lift", "rim" }, .{ "Motion", "playful" },
+ .{ "InactiveDim", "35" }, .{ "GripWidth", "200" }, .{ "CallstackDepth", "16" },
+ .{ "Tab", "8" }, .{ "SearchRows", "12" },
+ };
+ for (values) |v| try std.testing.expect(apply(&state, find(v[0]).?, v[1]));
try std.testing.expect(state.font.requested_name.set("Wanted Mono"));
try std.testing.expect(state.font.requested_path.set("/fonts/wanted.ttf"));
state.font.requested_size_hundredths = 1850;
@@ -1925,20 +1815,18 @@ pub const Runtime = struct {
state.font.pending = true;
state.font.effective_size_hundredths = 1375;
state.font.effective_size_unit = .points;
- state.font.tagline_percent = 82;
var out: std.Io.Writer = .fixed(&storage);
state.window_opacity_pending = false;
try writeReport(&out, context);
const report = storage[0..out.end];
+ var line: [64]u8 = undefined;
+ for (values) |v| try std.testing.expect(std.mem.indexOf(u8, report, try std.fmt.bufPrint(&line, "{s} {s}\n", .{ v[0], v[1] })) != null);
for ([_][]const u8{
- "Theme acme\n",
- "WindowOpacity 85\n",
"Font /fonts/wanted.ttf:18.50\n",
"# Font in use: Effective Mono 13.75 points\n",
"# Font change pending: on\n",
"# Window opacity change pending: off\n",
- "TaglineSize 82\n",
"# Startup config: /tmp/pardes/init\n",
"# Platform: gui\n",
"# Default shell ($SHELL, else /bin/sh): /bin/sh\n",
@@ -1961,34 +1849,21 @@ pub const Runtime = struct {
out = .fixed(&storage);
try writeReport(&out, defaults_context);
const defaults_report = storage[0..out.end];
- try std.testing.expect(std.mem.indexOf(u8, defaults_report, "WindowOpacity unsupported\n") != null);
- try std.testing.expect(!find("WindowOpacity").?.enabled(defaults_context.capabilities));
- try std.testing.expect(std.mem.indexOf(u8, defaults_report, "WindowBlur unsupported\n") != null);
- try std.testing.expect(!find("WindowBlur").?.enabled(defaults_context.capabilities));
- try std.testing.expect(find("WindowOpacity").?.enabled(context.capabilities));
- try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Shell /bin/sh\n") != null);
- try std.testing.expect(std.mem.indexOf(u8, defaults_report, "# Last shell spawned: (none)\n") != null);
- try std.testing.expect(std.mem.indexOf(u8, defaults_report, "# Shell change pending: on\n") != null);
- try std.testing.expect(std.mem.indexOf(u8, defaults_report, "# Startup config: no per-user config path\n") != null);
- try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Font unsupported\n") != null);
- try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Font in use") == null);
- try std.testing.expect(std.mem.indexOf(u8, defaults_report, "PanelSlide off\n") != null);
- try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Crt unsupported\n") != null);
- try std.testing.expect(std.mem.indexOf(u8, defaults_report, "TaglineSize unsupported\n") != null);
- try std.testing.expect(std.mem.indexOf(u8, defaults_report, "# Native images: off\n") != null);
// A setting this shell does not have reads so, as a comment.
- try std.testing.expect(std.mem.indexOf(u8, defaults_report, "# Ligatures unsupported\n") != null);
+ for ([_][]const u8{ "# WindowOpacity unsupported\n", "# WindowBlur unsupported\n", "# Font unsupported\n", "# Crt unsupported\n", "# TaglineSize unsupported\n", "# Ligatures unsupported\n" }) |expected|
+ try std.testing.expect(std.mem.indexOf(u8, defaults_report, expected) != null);
+ try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Font in use") == null);
// Every line before the blank one is a ctl word and its value, or a
// comment naming one.
const words = defaults_report[0..std.mem.indexOf(u8, defaults_report, "\n\n").?];
var lines = std.mem.splitScalar(u8, words, '\n');
- while (lines.next()) |line| {
- const word = if (std.mem.startsWith(u8, line, "# ")) line[2..] else line;
+ while (lines.next()) |each| {
+ const word = if (std.mem.startsWith(u8, each, "# ")) each[2..] else each;
try std.testing.expect(find(word[0..std.mem.indexOfScalar(u8, word, ' ').?]) != null);
}
// ...and every one after it a `#` line, which runs as nothing.
var info = std.mem.splitScalar(u8, std.mem.trimEnd(u8, defaults_report[words.len + 2 ..], "\n"), '\n');
- while (info.next()) |line| try std.testing.expect(std.mem.startsWith(u8, line, "# "));
+ while (info.next()) |each| try std.testing.expect(std.mem.startsWith(u8, each, "# "));
defaults_context.platform = "web";
defaults_context.capabilities.panel_transitions = false;
@@ -1996,8 +1871,7 @@ pub const Runtime = struct {
out = .fixed(&storage);
try writeReport(&out, defaults_context);
const web_report = storage[0..out.end];
- try std.testing.expect(std.mem.indexOf(u8, web_report, "PanelSlide unsupported\n") != null);
- try std.testing.expect(std.mem.indexOf(u8, web_report, "# TaglineSize unsupported\n") != null);
+ try std.testing.expect(std.mem.indexOf(u8, web_report, "# PanelSlide unsupported\n") != null);
try std.testing.expect(std.mem.indexOf(u8, web_report, "# Tagline size: build-time only\n") != null);
}
};