summaryrefslogtreecommitdiff
path: root/test/behaviour/addons.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 02:07:32 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commit83b9d45b8665a80bdb70934aa23bbde5cc03d202 (patch)
treec902b557ef624b07cd139659d0a891cd4809e03e /test/behaviour/addons.zig
parentb3d32656413734952bc918c2d4cfd12fede6c214 (diff)
downloadpardes-83b9d45b8665a80bdb70934aa23bbde5cc03d202.tar.gz
pardes-83b9d45b8665a80bdb70934aa23bbde5cc03d202.zip
plumber: a look sends what it looks at (docs/next-plumber.md, phase 2): after the pane's own readings and once a name already open in a pane is focused (never sent), lookAt sends the trimmed name, type text, src pardes (term from a raw terminal, a kind's name from its pane), wdir the pane's directory, with what resolveLookTarget found of it (Plumb.Seen: isfile and isdir take it, so no second stat and Look's own readings of a URL or `//` stay no file); a message the rules give back to `edit` as sent is Look's own (Sent.look) and runs lookAt's switch on that target, one nothing takes or a started word declines is Look's own too, whose `.url` arm is now the word's search; the edit port's open of another message runs with look_text, which now means "unplumbed", so the edit port's lookAt never sends again (the recursion trap); the three diff hooks become the default rules of the record's §5.2 (a bare .diff/.patch to `Diff $file`, a commit hash in the editor to `Diff $0`, after the two edit sets), and `Diff` takes a file or a revision, a rule's Diff declining in silence (Pardes.plumb_declined) where it cannot (no hunk, not readable, no .git above): hunks.lookedAt and lookedAtCommit go, their bodies in hunks.word, the `needs` check of the bare form in the word, PaneKind.diff gone; the old one-line `Plumb` word, Core.plumb, look.Port, plumbRuleError, plumbTarget and resolve's rules block go: bare, `Plumb` opens <config>/plumbing as Config opens init (both through builtins.openConfigFile; `include basic` in a new one), an argument is refused in words, Save applies it (host_io.writeFile beside reapplyInitFile, Plumb.saved), and boot reads it (Plumb.boot in applyStartupConfig); a started program now runs detached as Plan 9's plumber's (the coordinator's decision for the user's question 4): Effect.start, every host's host_io.startDetached (double fork, setsid, /dev/null for 0-2, every other fd closed, argv exec'd in wdir with no shell, the child's errno back through a close-on-exec pipe, said as `plumb start: <prog>: <why>`), so exec_dir goes; resolveLookTarget's and Plumb.Send.search's directory walk is one look.Dirs; test: look.zig's Plumb test rewritten onto the rules (a rule's word, an open pane unsent, the hover's resolve, a URL with no web rule searched for) and a hash inside and outside a git work tree; addons.zig's Plumb test onto plumb/rules (a port no kind reads, its kind gone: Look's own); Plumb.zig: the word, the save and boot; replicas.zig gains a URL (speculated whole, confirmed, no rollback) and a hash, each the authority's and a replica's own; every look golden unchanged; the reference quotes src/plumbing whole and says the order, the changelog says so
Diffstat (limited to 'test/behaviour/addons.zig')
-rw-r--r--test/behaviour/addons.zig13
1 files changed, 9 insertions, 4 deletions
diff --git a/test/behaviour/addons.zig b/test/behaviour/addons.zig
index 9b96a3d6..451cb1e3 100644
--- a/test/behaviour/addons.zig
+++ b/test/behaviour/addons.zig
@@ -185,7 +185,7 @@ test "addons: the image addon opens the pictures a Look names, fitted, with the
try std.testing.expect(has(try s.read("/screen"), "\"src\":[0,0,4,2]"));
}
-test "addons: a Plumb rule to a loaded kind opens that kind's pane, is refused naming one not loaded, and with its kind gone the look falls through to text" {
+test "addons: a plumbing rule to a loaded kind opens that kind's pane; to one not loaded, or with its kind gone, the look falls through to text" {
var s = try Session.initFile(std.testing.allocator, "x\n");
defer s.deinit();
try load(&s, Session.image_addon);
@@ -196,9 +196,14 @@ test "addons: a Plumb rule to a loaded kind opens that kind's pane, is refused n
// A PNG under a name no kind claims.
const png = "\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x02\x00\x00\x00\x90wS\xde\x00\x00\x00\x0cIDATx\x9cc\xf8\xcf\xc0\x00\x00\x03\x01\x01\x00\xc9\xfe\x92\xef\x00\x00\x00\x00IEND\xaeB`\x82";
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "red.pic", .data = png });
- try std.testing.expect(try s.refused("/ctl", "Plumb suffix .pic to nokind\n") != 0);
- try std.testing.expect(has(s.said, "Plumb: invalid port: url, dir, file or a loaded kind"));
- try s.write("/ctl", "Plumb suffix .pic to image\n");
+ // A port no kind reads is no refusal (plumber(4) never refuses one):
+ // nothing reads it, the rule set starts nothing, and Look looks itself.
+ const rule = "type is text\ndata matches '.*\\.pic'\narg isfile $data\nplumb to {s}\n\ninclude basic\n";
+ try s.replace("/plumb/rules", s.at(rule, .{"nokind"}));
+ try s.write("/look", s.at("{s}/red.pic\n", .{dir}));
+ try std.testing.expect(has(try s.read(s.at("/pane/{d}/tag", .{try s.focused()})), "red.pic"));
+ try s.write(s.at("/pane/{d}/ctl", .{try s.focused()}), "Del\n");
+ try s.replace("/plumb/rules", s.at(rule, .{"image"}));
try s.write("/look", s.at("{s}/red.pic\n", .{dir}));
try std.testing.expectEqual(try paneOf(&s, "image"), try s.focused());
try s.write(s.at("/pane/{d}/ctl", .{try s.focused()}), "Del\n");