summaryrefslogtreecommitdiff
path: root/core/replica.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/replica.zig')
-rw-r--r--core/replica.zig25
1 files changed, 25 insertions, 0 deletions
diff --git a/core/replica.zig b/core/replica.zig
index ff1e138e..f3269c84 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -7364,6 +7364,31 @@ test "a client joined while a script's writes to a body are held to go in as one
try n.agree();
}
+test "a client runs an Edit a script's write started once, as its session does, when the held write is asked again" {
+ var n = try NinepJoin.init("b\na\n", TestHost.host());
+ defer n.deinit();
+ try n.join();
+ const ctl = n.node(.ctl);
+ const req: pardes.ctlfs.Req = .{ .tag = 7, .op = .write, .node = ctl, .data = "Edit , | sort\n" };
+ // The step alone: its loop's pass would run the command (here, with no
+ // host to run it, fail it).
+ const first = try n.serve(req, false);
+ try std.testing.expectEqual(pardes.ctlfs.Status.ok, first.status);
+ // The write held as the session's listener holds it (runtime/9p_io.zig).
+ n.a.core.fs.edit_hold = .{ .asker = @ptrCast(n.a.core), .slot = 0, .seq = 1, .tag = req.tag, .node = ctl, .handle = 0, .written = first.written };
+ // Its command answers: the Edit is done.
+ n.a.apply(.{ .pipe_resp = .{ .id = n.a.core.pipe.edit_run.?.id, .success = true, .outputs = &.{"a\nb\n"} } });
+ n.a.seq += 1;
+ try n.send(try n.a.unit(0, n.a.seq));
+ try n.agree();
+ // A retry of the held write's park, as the listener serves it: its
+ // answer from the hold, no step, the Edit not run again by anyone.
+ const again = pardes.filesystem.EditHold.retried(&n.a.core.fs, req) orelse try n.serve(req, true);
+ try std.testing.expectEqual(pardes.ctlfs.Status.ok, again.status);
+ try std.testing.expect(n.a.core.pipe.edit_run == null);
+ try n.agree();
+}
+
/// A session with a shell, for a run's 9P state across a join: a host
/// whose pty takes the line and whose tty nobody else holds.
const RunJoin = struct {