summaryrefslogtreecommitdiff
path: root/test/behaviour
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-26 21:45:46 -0300
committerGabriel Schneider <[email protected]>2026-11-26 23:24:00 -0300
commit24dc19130fd6a063bb7e86fa21a02d7af4c3b163 (patch)
tree761d6a1b439f5ea31f3679c8b4f2874e0acfbeb7 /test/behaviour
parent8d2a064eb69a1f888c435c3a0e03468b59abbb0d (diff)
downloadpardes-24dc19130fd6a063bb7e86fa21a02d7af4c3b163.tar.gz
pardes-24dc19130fd6a063bb7e86fa21a02d7af4c3b163.zip
Root, and the explicit root keys SPC f F, SPC f G and SPC :: Find, Grep and the `:` line run at the project's root, the nearest directory at or above the asking pane's holding a `.jj` or a `.git` (Pick.workTree, kept by zxsqtpol for this), the pane's own when none does, while SPC f f, SPC f g and `:` keep acme's directory (the user's ruling of 2026-11-26: "maybe some commands SHOULD run on the project root for convenience", explicit twins, nothing implicit); WHY A WORD: a leader leaf names a builtin (config.leader_path, leader_args) and `:` is a normal-mode role, so the three keys need one word that reaches the root: `Root <line>` runs the line as Exec does with the step's flag Pardes.exec_root set, bare (SPC :) it opens the `:` line marked to run there, and a script's `Root make` or `Root Grep x` falls out of it at a ctl for free; THE CHANGE: builtins.Root; Pardes.exec_root, a step's own (replica `.local`, root.zig's kept_out) like exec_column; execDir reads the root under it (a command pane's directory, Term's, and Query.create's, which now calls execDir in place of its copy of it); executeFrom sends Root's line to a command pane even from a shell at its prompt, and runCommand reuses only a finished command pane at the root for it (not the asking one); Pick.root: a picker Root asked lists from the root, its head `␣ f Find root`, `Grep root`, its list word `Find root …`, Exec on that word running at the root again, a Grep's leading directory read from the root (grepScope, unchanged); Command.root: SPC :'s line, its head `: root`, `= Root make` as its plain word, its Enter and its `:open ` run as Root; config: Root's leader path `:`, leader_args fF and fG run `Root Find` and `Root Grep`, which-key labels `Find root` and `Grep root` (bindings.zig); replica's may_wait gets back a kind row, `Root *` (the root's stat on the session's disk), walked as `Root Find` (walk_samples: bare Root, the `:` line, asks the disk nothing); docs: Root's own doc (the Help index row `SPC : Root`, builtins-tui.json from `zig build builtins-json`, the same line put in builtins-gui.json), the cheatsheet's leader list (three short rows), guide.typ's Find and Grep rows and its where-commands-run table; RUN (TEST FIRST): behaviour/find_grep.zig (the reference's Find and Grep chapter, new): a `.jj` project, `x.txt` two directories below it: SPC f f lists `x.txt` alone and no `Find root`, SPC f F `␣ f Find root` with `a/b/x.txt` and `top.txt` (`.jj` passed over); SPC f G `needle` `␣ f Grep root needle` with `a/b/x.txt:1 needle below` and `top.txt:1 … needle at the top`, `a needle` the first alone (a/ is the root's); look_and_exec.zig: `:pwd` makes a command pane named `<root>/a/b`, SPC : shows `: root` and its `pwd` a second command pane named `<root>` (a `.git` project), each body `% pwd`; the three fail on zxsqtpol 8d2a064eb69a (`not on the screen: ␣ f Find root`, `… ␣ f Grep root needle`, `… : root`), pass now; test/session.zig gains `advance`, the host's clock moved on, so a typed Grep's 80 ms pause comes due in a T1 test; REAL CHECK (a private detached session of this Debug build over 9P, CA's demo copied with a `.jj` at its top): from src/torque/types.cc SPC f f types.cc types.h, SPC f F `Find root` Makefile compile_commands.json src/torque/types.cc … 1/5, SPC f G ToString `Grep root` three hits from the root, `src ToString` narrowed, `:pwd` printed …/demo/src/torque, SPC : `: root`, `: root make = Root make`, its pwd printed …/demo, its make ran `clang++ … src/torque/types.cc` at the root (exit 2, the demo's error) and SPC e from types.cc walked to types.cc:7:11, `SPC :open Make` opened `Find root Make`; GOLDENS (process-test --update, read): leader.golden spc and unmapped (`: Root` after `/ All` in SPC's level), find.golden group (`F Find root`, `G Grep root` in SPC f's), nothing else moved; NO hot path (a stat per directory up to the root once per Root run; a flag and five bytes in the head); the dump and the digest gain two bools (Pick.root, Command.root): the 40,000-seed dump fuzz (40,000 + 40,000 join seeds, 1,779 image seeds) 11/11, core/fuzz.zig restored byte for byte; GATES: Debug core-test 1172/1349 (177 skipped), shell-test 1390/1393 (3 skipped; the walk with Root's row), addons 8/8, term-test 17/17, kitty-test 45/45, process-test 0 of 149 failed (3 skipped), pane-test 184/185, behaviour-test 293/293 and --replay 293/293 (+3), consumer-test, the soak twice (rtt 30/80/207: diverged 0, unequal 0, quiet checks 617/0 485/0 568/0 and 499/0 387/0 553/0, unlisted stops 0, the corpus 22 of 22 scenes the same, no leak), daemon.py plain x3, games, window-clients, clients x5, relink, launch, pair, gui, client-motion rc 0, far rc 1 (`no link of the far client ended under the flood`, as on the base), client-resize-real skipped (no compositor), the macOS x86_64 and arm64 and FreeBSD cross-builds; ReleaseSafe: the build (0 invalid options), the soak (diverged 0, unequal 0, quiet checks 514/0 381/0 543/0, unlisted stops 0), process-test 1 of 149 failed (root-ctl Restore, as on the base), upgrade from the installed ab9fa40a7bbb, upgrade-gui, upgrade-self (65 s) and upgrade-back (40 s) each nothing left behind, launch, clients x3, far, gui, client-motion, client-resize-real, client-idle, pair, plain x3 rc 0; load 1.2 to 3.6
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'test/behaviour')
-rw-r--r--test/behaviour/find_grep.zig63
-rw-r--r--test/behaviour/look_and_exec.zig21
2 files changed, 84 insertions, 0 deletions
diff --git a/test/behaviour/find_grep.zig b/test/behaviour/find_grep.zig
new file mode 100644
index 00000000..49bf64aa
--- /dev/null
+++ b/test/behaviour/find_grep.zig
@@ -0,0 +1,63 @@
+//! docs/typ/reference.typ, Find and Grep <find-grep>.
+const std = @import("std");
+const Session = @import("session").Session;
+
+fn has(haystack: []const u8, needle: []const u8) bool {
+ return std.mem.indexOf(u8, haystack, needle) != null;
+}
+
+/// A project in `tmp`: a `.jj` at its top, `top.txt` there and `x.txt`
+/// two directories below, in `a/b`, each holding `needle`; its path.
+fn project(s: *Session, tmp: *std.testing.TmpDir) ![]const u8 {
+ try tmp.dir.createDirPath(std.testing.io, ".jj");
+ try tmp.dir.createDirPath(std.testing.io, "a/b");
+ try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "top.txt", .data = "needle at the top\n" });
+ try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "a/b/x.txt", .data = "needle below\n" });
+ var buf: [4096]u8 = undefined;
+ return s.arena.allocator().dupe(u8, buf[0..try tmp.dir.realPath(std.testing.io, &buf)]);
+}
+
+test "find-grep: SPC f f lists the files of the pane's directory, SPC f F those of the project's root above it, its head `Find root`" {
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const root = try project(&s, &tmp);
+ _ = try s.lookFile(s.at("{s}/a/b/x.txt", .{root}));
+ try s.keys(" ff");
+ s.tick();
+ _ = try s.where("▶ x.txt");
+ try std.testing.expect(!has(try s.screen(), "top.txt"));
+ try std.testing.expect(!has(try s.screen(), "Find root"));
+ try s.keys("\x1b");
+ // From the root: its files by their paths from it, `.jj` passed over.
+ try s.keys(" fF");
+ s.tick();
+ _ = try s.where("␣ f Find root");
+ _ = try s.where(" a/b/x.txt");
+ _ = try s.where(" top.txt");
+ try std.testing.expect(!has(try s.screen(), ".jj"));
+}
+
+test "find-grep: SPC f G greps from the project's root above the pane's directory, its head `Grep root`, a leading directory narrowing it from the root" {
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const root = try project(&s, &tmp);
+ _ = try s.lookFile(s.at("{s}/a/b/x.txt", .{root}));
+ try s.keys(" fGneedle");
+ s.advance(100 * std.time.ns_per_ms);
+ s.tick();
+ _ = try s.where("␣ f Grep root needle");
+ // Each row its place from the root, the places' column padded.
+ _ = try s.where("a/b/x.txt:1 needle below");
+ _ = try s.where("top.txt:1 needle at the top");
+ try s.keys("\x1b");
+ // `a needle`: the root's a/, which the pane's directory has not.
+ try s.keys(" fGa needle");
+ s.advance(100 * std.time.ns_per_ms);
+ s.tick();
+ _ = try s.where("a/b/x.txt:1 needle below");
+ try std.testing.expect(!has(try s.screen(), "top.txt:1"));
+}
diff --git a/test/behaviour/look_and_exec.zig b/test/behaviour/look_and_exec.zig
index 3e6137b1..387c28a7 100644
--- a/test/behaviour/look_and_exec.zig
+++ b/test/behaviour/look_and_exec.zig
@@ -442,6 +442,27 @@ fn tmpPath(s: *Session, tmp: *std.testing.TmpDir) ![]const u8 {
return s.at("{s}", .{buf[0..try tmp.dir.realPath(std.testing.io, &buf)]});
}
+test "look-and-exec: SPC : runs its line in a command pane at the project's root, the nearest directory at or above the pane's holding a .jj or a .git, where `:` runs it in the pane's own; its head `: root`" {
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ try tmp.dir.createDirPath(std.testing.io, ".git");
+ try tmp.dir.createDirPath(std.testing.io, "a/b");
+ try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "a/b/x.txt", .data = "x\n" });
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const root = try tmpPath(&s, &tmp);
+ _ = try s.lookFile(s.at("{s}/a/b/x.txt", .{root}));
+ try s.keys(":pwd\n");
+ const here = try paneNamed(&s, s.at("{s}/a/b", .{root}));
+ try std.testing.expect(std.mem.startsWith(u8, try s.read(s.at("/pane/{d}/body", .{here})), "% pwd\n"));
+ try s.keys(" :");
+ _ = try s.where(": root");
+ try s.keys("pwd\n");
+ const at_root = try paneNamed(&s, root);
+ try std.testing.expect(at_root != here);
+ try std.testing.expect(std.mem.startsWith(u8, try s.read(s.at("/pane/{d}/body", .{at_root})), "% pwd\n"));
+}
+
test "look-and-exec: a look opens spaced paths and locations without editing the source pane" {
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();