diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 11:09:10 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-04 11:17:24 -0300 |
| commit | a5504e6e808c5b147e114d43b5c165bbe714f3c3 (patch) | |
| tree | 81d61c2d451a8715ca076088414be226dd49cb9a /test/output.zig | |
| parent | fa3031d6ded24d4ba7ab5bab21e17387e48306aa (diff) | |
| download | pardes-a5504e6e808c5b147e114d43b5c165bbe714f3c3.tar.gz pardes-a5504e6e808c5b147e114d43b5c165bbe714f3c3.zip | |
test: test/output.zig's Mini, setting and command-output LookNext tests through the 9P tree alone: in a new test/behaviour/builtins.zig (docs/typ/builtins.typ) Mini mapping a file of the pane's directory over pardes's own of that name, one pane for it, a snapshot refreshed only by the next Mini, and Save on it writing nothing (the old test trimmed to the watch it never asks for, an effect); in test/behaviour/settings.zig every on/off setting the root ctl reads flipping when its word is written bare, and Theme and Shell taking a value (the old test trimmed to a window's fonts, transitions and passes in DumpConfig's report); in test/behaviour/keys.zig SPC j n in a command output (+Themes) selecting its whole row, Tab running it, and from a pane a Look took the keyboard to walking on in it, and SPC j n and SPC j p walking on and back from the place a Look's +Search listing chose (the old test trimmed to its fillResults answers); each checked to fail against a break (Mini making a new pane each time, a setting's bare word not flipping it, a command output's grain a word, the walk's owner forgotten)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/output.zig')
| -rw-r--r-- | test/output.zig | 70 |
1 files changed, 9 insertions, 61 deletions
diff --git a/test/output.zig b/test/output.zig index 3cfece45..876cd8fc 100644 --- a/test/output.zig +++ b/test/output.zig @@ -389,7 +389,9 @@ test "result stepping reaches an unterminated last row" { try std.testing.expectEqual(@as(i32, 1), result.body.cur_row); } -test "Mini uses OS source precedence and refreshes one independent snapshot" { +// What it shows and when it refreshes is test/behaviour/builtins.zig's; +// the watch it never asks for is an effect, unseen through 9P. +test "Mini asks for no watch on its pane" { var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "build.zig", .data = "x\n" }); @@ -401,27 +403,11 @@ test "Mini uses OS source precedence and refreshes one independent snapshot" { try std.testing.expect(p.executeBuiltinLine(0, "Mini build.zig")); const id = p.active; try std.testing.expect(id != 0); - const mini = p.panes[id].?; - try std.testing.expect(mini.terminal == null); - try std.testing.expectEqualStrings("⠁\n", mini.file.?.content); - try std.testing.expect(std.mem.startsWith(u8, mini.file.?.mini.?.source, dir)); - const next = p.freeSlot(); - const body = mini.file.?.content.ptr; - try std.testing.expect(p.executeBuiltinLine(id, "Mini build.zig")); - try std.testing.expectEqual(id, p.active); - try std.testing.expectEqual(body, mini.file.?.content.ptr); - try std.testing.expectEqual(next, p.freeSlot()); - try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "build.zig", .data = "xx\n" }); - try std.testing.expectEqualStrings("⠁\n", mini.file.?.content); try std.testing.expect(p.executeBuiltinLine(id, "Mini build.zig")); - try std.testing.expectEqual(id, p.active); - try std.testing.expectEqualStrings("⠉\n", mini.file.?.content); while (p.nextEffect()) |effect| switch (effect) { .watch => |watch| try std.testing.expect(watch.pane != id), else => {}, }; - try std.testing.expect(p.executeBuiltinLine(id, "Save")); - try std.testing.expect(mini.prompt == .save); } test "Mini dump preserves its exact virtual snapshot and body writes detach colors" { @@ -617,7 +603,7 @@ test "EffectCode lists readable virtual sources used by this backend" { try std.testing.expectEqualStrings(pardes.filesystem.sourceBytes(backend_source["/virtual/".len..]).?, source.content); } -test "every enabled setting builtin mutates the State Config reports" { +test "a window's setting builtins (TaglineSize, Font, transitions, scene passes) reach the report DumpConfig writes" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); p.locations_config.layout = .@"inline"; @@ -653,14 +639,8 @@ test "every enabled setting builtin mutates the State Config reports" { try std.testing.expect(p.executeBuiltinLine(p.active, "DumpConfig")); const report = p.panes[p.active].?.file.?.content; - for ([_][]const u8{ - "Colors off\n", - "Wrap off\n", - "Tagbottom on\n", - "Debug on\n", - "Theme acme\n", - "Shell fish\n", - }) |line| try std.testing.expect(std.mem.indexOf(u8, report, line) != null); + // The toggles, Theme and Shell are test/behaviour/settings.zig's, through + // the root ctl; what is left is a window's (fonts, transitions, passes). const transition = if (!builtins.viewCapabilities(p).panel_transitions) "PanelSlide unsupported\n" else if (p.settings.panel_transition == .off) @@ -821,7 +801,7 @@ test "LookNext/LookPrev selects one output location per row and opens nothing" { try std.testing.expectEqual(panes.Output.Grain.word, panes.Output.grain(p.panes[p.active].?.file.?.output)); } -test "LookNext/LookPrev resumes the result output whose Look moved focus away" { +test "LookNext/LookPrev keeps the result output a Look chose through a no-match answer, and a stale serial once it is deleted" { if (platform == .web) return; var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); @@ -844,12 +824,8 @@ test "LookNext/LookPrev resumes the result output whose Look moved focus away" { try std.testing.expect(results.look_at != null); try std.testing.expectEqual(results.serial, p.look_walk_owner orelse return error.MissingLookOwner); - lookKey(p, 'n'); - try std.testing.expectEqual(rid, p.active); - try std.testing.expectEqual(first + 1, results.body.cur_row); - lookKey(p, 'N'); - try std.testing.expectEqual(first, results.body.cur_row); - + // The walk on and back from it is test/behaviour/keys.zig's; what is + // left needs answers put in by fillResults. // A later no-match answer has no position to resume and therefore cannot // steal the provenance established by the Look above. const owner = results.serial; @@ -924,34 +900,6 @@ test "LookPrev exactly reverses LookNext across output panes and the ring seam" try std.testing.expect(saw_first and saw_second); } -test "LookNext/LookPrev selects command outputs by whole row" { - if (platform == .web) return; - var cwd_buf: [4096]u8 = undefined; - var path_buf: [4096]u8 = undefined; - const paths = try projectPaths(&cwd_buf, &path_buf); - const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 40, .file = paths.boot }); - defer p.deinit(); - p.update(.{ .resize = .{ .cols = 100, .rows = 40 } }); - - try std.testing.expect(p.executeBuiltinLine(p.active, "Themes")); - const tid = p.panes[p.active].?.search_pane orelse return error.MissingThemeList; - const themes = p.panes[tid].?; - try std.testing.expect(panes.Output.fileTraits(themes.file.?.output).commands); - lookKey(p, 'n'); - const row0 = std.mem.trimEnd(u8, modal.lineSlice(themes.file.?.content, 1), " \t\r"); - try std.testing.expectEqualStrings(row0, selectedOutputText(themes) orelse ""); - const theme_before = p.settings.theme; - lookKey(p, 'n'); - p.update(.{ .key = .{ .cp = Key.tab } }); - try std.testing.expect(p.settings.theme != theme_before); - - try std.testing.expect(p.executeBuiltinLine(0, "Look build.zig")); - p.update(.tick); - try std.testing.expect(p.active != 0); - lookKey(p, 'n'); - try std.testing.expectEqual(@as(usize, 0), p.active); -} - test "identical result refresh keeps warm content caches without allocation" { var allocator: std.testing.FailingAllocator = .init(std.testing.allocator, .{}); const p = try Pardes.init(allocator.allocator(), .{ .tty_only = true, .cols = 80, .rows = 24 }); |
