summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-09 00:52:52 -0300
committerGabriel Schneider <[email protected]>2026-11-09 01:28:28 -0300
commit5157579ff7f9ae0cfc3c7629e953da05bce340fc (patch)
tree02147789efdcea998981efcfe05d4bcb3e9bb7b0 /src/builtins.zig
parent4c4b9bf54d77dbc0f9f4e2619746908e501c6001 (diff)
downloadpardes-5157579ff7f9ae0cfc3c7629e953da05bce340fc.tar.gz
pardes-5157579ff7f9ae0cfc3c7629e953da05bce340fc.zip
tests: at the end of their files: every top-level test block of the 46 files that had one mid-file (the locality analysis's 45 and test/hxdiff.zig; gui.zig, macos.zig, look, host_io, 9p_io, terminal, tui, mouse, fs, replica, layout among them, 11,429 test lines), with the functions only tests call, moved after the file's code in their order, a mechanical move (.scratch/suites/tests_to_end.py), zig fmt'd; the unit suites pass as before (tui 1486/1487, gui 1536/1537, core 956/956 on both), macos.zig only parse-checked here
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/builtins.zig')
-rw-r--r--src/builtins.zig422
1 files changed, 211 insertions, 211 deletions
diff --git a/src/builtins.zig b/src/builtins.zig
index c41b3e1b..2e8397e6 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -269,217 +269,6 @@ pub const registry = struct {
}
};
-test "capabilities exactly gate setting builtins" {
- const Builtin = registry.Builtin();
- for (config.Runtime.settings) |setting| {
- const registered = std.meta.stringToEnum(Builtin, setting.word) != null;
- try std.testing.expectEqual(setting.enabled(capabilities), registered);
- }
-}
-
-test "a builtin's scope is the pane unless it says session, and every setting is the session's" {
- const Builtin = registry.Builtin();
- try std.testing.expectEqual(Scope.pane, registry.scope(Builtin.Del));
- try std.testing.expectEqual(Scope.pane, registry.scope(Builtin.Save));
- try std.testing.expectEqual(Scope.session, registry.scope(Builtin.Newcol));
- try std.testing.expectEqual(Scope.session, registry.scope(Builtin.Kill));
- try std.testing.expectEqual(Scope.session, registry.scope(Builtin.Verbose));
- for (comptime settingList()) |setting|
- try std.testing.expectEqual(Scope.session, registry.scope(std.meta.stringToEnum(Builtin, setting.word).?));
-}
-
-test "Exit asks once about unsaved text, and quits when asked again" {
- const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
- defer p.deinit();
- const pane = try p.setTestFile("saved\n");
- pane.file.?.saved_revision = pane.file.?.revision -% 1; // modified
- pane.file.?.saved_hash = 0; // edited: what it had is not what it has
- try std.testing.expect(p.executeBuiltinLine(p.view().active, "Exit"));
- try std.testing.expect(!p.quit);
- try std.testing.expect(std.mem.endsWith(u8, unsavedList(p), ": Modified\n\nExit again to discard\n"));
- // Told once, and nothing edited since: the second Exit quits.
- try std.testing.expect(p.executeBuiltinLine(p.view().active, "Exit"));
- try std.testing.expect(p.quit);
-}
-
-test "Exit over a ctl write or a click names every pane it asks about, a second only those edited since, and the next discards them all" {
- for ([_]bool{ false, true }) |clicked| {
- const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
- defer p.deinit();
- const first = try p.setTestFile("saved\n");
- first.file.?.saved_revision = first.file.?.revision -% 1;
- first.file.?.saved_hash = 0; // edited: what it had is not what it has
- p.newScratchBelow(p.view().active);
- const second = p.panes[p.view().active].?;
- panes.File.setContent(p, &second.file.?, try std.testing.allocator.dupe(u8, &@as([120]u8, @splat('x'))));
- try std.testing.expect(second.file.?.revision != second.file.?.saved_revision);
- // A ctl write, or a click through exec (ctl.captured).
- if (clicked) p.fs.capturing = true else p.fs.no_prompt = true;
- defer p.fs.capturing = false;
- defer p.fs.no_prompt = false;
- try std.testing.expect(p.executeBuiltinLine(p.view().active, "Exit"));
- try std.testing.expect(!p.quit);
- // Two: counted, never a list cut short; `unsaved` records name them.
- try std.testing.expectEqualStrings("2 unsaved panes: Modified (Exit again to discard)", p.fs.failure[0..p.fs.failure_len]);
- const log = p.fs.log.buf.items;
- var rec: [64]u8 = undefined;
- for ([_]*const Pane{ first, second }) |pane|
- try std.testing.expect(std.mem.indexOf(u8, log, try std.fmt.bufPrint(&rec, "unsaved {d} ", .{pane.serial})) != null);
- // The whole list stays in +Unsaved; the notice is short.
- try std.testing.expect(std.mem.indexOf(u8, unsavedList(p), first.file.?.path) != null);
- try std.testing.expect(std.mem.endsWith(u8, unsavedList(p), "\nExit again to discard\n"));
- var noticed = false;
- for (p.panes) |slot| if (slot) |pane| {
- noticed = noticed or std.mem.eql(u8, pane.msg[0..pane.msg_len], "2 unsaved panes \u{2014} Exit again to discard");
- };
- try std.testing.expect(noticed);
- // Edited since: only that one is named again (acme's rule).
- p.fs.failure_len = 0;
- panes.File.setContent(p, &second.file.?, try std.testing.allocator.dupe(u8, &@as([120]u8, @splat('y'))));
- try std.testing.expect(p.executeBuiltinLine(p.view().active, "Exit"));
- try std.testing.expect(!p.quit);
- const again = p.fs.failure[0..p.fs.failure_len];
- try std.testing.expect(std.mem.indexOf(u8, again, first.file.?.path) == null);
- // The one +Unsaved, filled again.
- var kept: usize = 0;
- for (p.panes) |slot| if (slot) |pane| if (pane.file) |f| if (f.output) |o| {
- kept += @intFromBool(o.from == .unsaved);
- };
- try std.testing.expectEqual(@as(usize, 1), kept);
- try std.testing.expect(std.mem.indexOf(u8, unsavedList(p), first.file.?.path) == null);
- try std.testing.expect(std.mem.startsWith(u8, again, second.file.?.path));
- p.fs.failure_len = 0;
- try std.testing.expect(p.executeBuiltinLine(p.view().active, "Exit"));
- try std.testing.expect(p.quit);
- }
-}
-
-/// What +Unsaved holds: the list a refusal over unsaved panes keeps.
-fn unsavedList(p: *Pardes) []const u8 {
- for (p.panes) |slot| if (slot) |pane| if (pane.file) |f| if (f.output) |o| if (o.from == .unsaved) return f.content;
- return "";
-}
-
-/// A dump file that exists, for a Restore to get past reading it.
-fn testDump(buf: []u8) ![]const u8 {
- var tmp = std.testing.tmpDir(.{});
- // A real dump: a Restore reads it through before it asks anything.
- const source = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
- defer source.deinit();
- try pardes.dump.dumpState(source);
- try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "d.zon", .data = source.dump_out.? });
- var dir: [4096]u8 = undefined;
- const at = dir[0..try tmp.dir.realPath(std.testing.io, &dir)];
- return std.fmt.bufPrint(buf, "Restore {s}/d.zon", .{at});
-}
-
-test "Restore asks about unsaved text as Exit does, and restores when asked again" {
- const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
- defer p.deinit();
- const pane = try p.setTestFile("saved\n");
- pane.file.?.saved_revision = pane.file.?.revision -% 1; // modified
- pane.file.?.saved_hash = 0; // edited: what it had is not what it has
- var line_buf: [4200]u8 = undefined;
- const line = try testDump(&line_buf);
- try std.testing.expect(p.executeBuiltinLine(p.view().active, line));
- try std.testing.expect(p.restore_req == null);
- try std.testing.expect(std.mem.endsWith(u8, unsavedList(p), ": Modified\n\nRestore again to discard\n"));
- try std.testing.expect(p.executeBuiltinLine(p.view().active, line));
- try std.testing.expectEqualStrings(line["Restore ".len..], p.restore_req.?);
-}
-
-test "a Restore of a dump that cannot be read says so, before the unsaved-text warning" {
- const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
- defer p.deinit();
- const pane = try p.setTestFile("saved\n");
- pane.file.?.saved_revision = pane.file.?.revision -% 1; // modified
- pane.file.?.saved_hash = 0; // edited: what it had is not what it has
- p.fs.no_prompt = true;
- defer p.fs.no_prompt = false;
- try std.testing.expect(p.executeBuiltinLine(p.view().active, "Restore /nope/missing.zon"));
- try std.testing.expect(p.restore_req == null);
- try std.testing.expectEqualStrings("Restore: /nope/missing.zon: no such file", p.fs.failure[0..p.fs.failure_len]);
- // No warning spent: the Exit after it still asks.
- try std.testing.expect(pane.discard_warned == null);
-}
-
-test "a Restore's warning is not an Exit's: each word is warned on its own" {
- const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
- defer p.deinit();
- const pane = try p.setTestFile("saved\n");
- pane.file.?.saved_revision = pane.file.?.revision -% 1; // modified
- pane.file.?.saved_hash = 0; // edited: what it had is not what it has
- var line_buf: [4200]u8 = undefined;
- try std.testing.expect(p.executeBuiltinLine(p.view().active, try testDump(&line_buf)));
- try std.testing.expect(p.restore_req == null);
- // The Restore warned; an Exit after it has not been, and asks.
- try std.testing.expect(p.executeBuiltinLine(p.view().active, "Exit"));
- try std.testing.expect(!p.quit);
- try std.testing.expect(std.mem.endsWith(u8, unsavedList(p), ": Modified\n\nExit again to discard\n"));
- try std.testing.expect(p.executeBuiltinLine(p.view().active, "Exit"));
- try std.testing.expect(p.quit);
-}
-
-test "Kill stops the commands pardes typed, bare all and by name those that match, and never quits" {
- const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 });
- defer p.deinit();
- while (p.nextEffect()) |_| {}
- const term = p.view().active;
- try std.testing.expect(p.panes[term].?.isTerminal());
- const prompt = "\x1b]133;A;cl=line;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07";
- p.update(.{ .output = .{ .pane = @intCast(term), .bytes = prompt } });
- while (p.nextEffect()) |_| {}
- // The host the core asks: how many it was asked to stop, and whether
- // their shells run jobs in groups of their own.
- const killed = struct {
- var asked: usize = 0;
- var job_control = true;
- const vtable: pardes.Host.VTable = .{ .kill_job = answer };
- fn answer(_: ?*anyopaque, _: u8) bool {
- asked += 1;
- return job_control;
- }
- fn count(pp: *Pardes, line: []const u8) usize {
- asked = 0;
- _ = pp.executeBuiltinLine(pp.view().active, line);
- return asked;
- }
- };
- p.host = .{ .vtable = &killed.vtable };
- // Nothing running: nothing to stop, and never the shell; said.
- try std.testing.expectEqual(@as(usize, 0), killed.count(p, "Kill"));
- try std.testing.expectEqualStrings("Kill: nothing running", p.panes[term].?.msg[0..p.panes[term].?.msg_len]);
- _ = exec.execute(p, term, "make -j8");
- while (p.nextEffect()) |_| {}
- // Typed but not started yet (no C mark): not running.
- try std.testing.expectEqual(@as(usize, 0), killed.count(p, "Kill"));
- p.update(.{ .output = .{ .pane = @intCast(term), .bytes = "\x1b]133;C;aid=pardes\x07" } });
- while (p.nextEffect()) |_| {}
- try std.testing.expectEqual(@as(usize, 0), killed.count(p, "Kill ls"));
- try std.testing.expectEqual(@as(usize, 1), killed.count(p, "Kill ls make"));
- try std.testing.expectEqual(@as(usize, 1), killed.count(p, "Kill"));
- try std.testing.expect(!p.quit);
- // With job control off there is no job apart from the shell: said, and
- // over ctl the write fails with it.
- killed.job_control = false;
- p.fs.no_prompt = true;
- try std.testing.expectEqual(@as(usize, 1), killed.count(p, "Kill"));
- try std.testing.expectStringStartsWith(p.fs.failure[0..p.fs.failure_len], "Kill: no job to signal");
- p.fs.no_prompt = false;
- p.fs.failure_len = 0;
- killed.job_control = true;
- // Ended (a D mark): nothing to stop again.
- p.update(.{ .output = .{ .pane = @intCast(term), .bytes = "\x1b]133;D;143;aid=pardes\x07" ++ prompt } });
- while (p.nextEffect()) |_| {}
- try std.testing.expectEqual(@as(usize, 0), killed.count(p, "Kill"));
-}
-
-test "Look does not announce itself on the message row; Del still does" {
- const Builtin = registry.Builtin();
- try std.testing.expect(!registry.announces(Builtin.Look));
- try std.testing.expect(registry.announces(Builtin.Del));
-}
-
// ---- the two acme verbs ----
/// Look at its argument: open the file or address it names, else find the word, as a right click does.
@@ -2061,6 +1850,217 @@ pub const Lspwhy = struct {
}
};
+/// What +Unsaved holds: the list a refusal over unsaved panes keeps.
+fn unsavedList(p: *Pardes) []const u8 {
+ for (p.panes) |slot| if (slot) |pane| if (pane.file) |f| if (f.output) |o| if (o.from == .unsaved) return f.content;
+ return "";
+}
+
+/// A dump file that exists, for a Restore to get past reading it.
+fn testDump(buf: []u8) ![]const u8 {
+ var tmp = std.testing.tmpDir(.{});
+ // A real dump: a Restore reads it through before it asks anything.
+ const source = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
+ defer source.deinit();
+ try pardes.dump.dumpState(source);
+ try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "d.zon", .data = source.dump_out.? });
+ var dir: [4096]u8 = undefined;
+ const at = dir[0..try tmp.dir.realPath(std.testing.io, &dir)];
+ return std.fmt.bufPrint(buf, "Restore {s}/d.zon", .{at});
+}
+
+test "capabilities exactly gate setting builtins" {
+ const Builtin = registry.Builtin();
+ for (config.Runtime.settings) |setting| {
+ const registered = std.meta.stringToEnum(Builtin, setting.word) != null;
+ try std.testing.expectEqual(setting.enabled(capabilities), registered);
+ }
+}
+
+test "a builtin's scope is the pane unless it says session, and every setting is the session's" {
+ const Builtin = registry.Builtin();
+ try std.testing.expectEqual(Scope.pane, registry.scope(Builtin.Del));
+ try std.testing.expectEqual(Scope.pane, registry.scope(Builtin.Save));
+ try std.testing.expectEqual(Scope.session, registry.scope(Builtin.Newcol));
+ try std.testing.expectEqual(Scope.session, registry.scope(Builtin.Kill));
+ try std.testing.expectEqual(Scope.session, registry.scope(Builtin.Verbose));
+ for (comptime settingList()) |setting|
+ try std.testing.expectEqual(Scope.session, registry.scope(std.meta.stringToEnum(Builtin, setting.word).?));
+}
+
+test "Exit asks once about unsaved text, and quits when asked again" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
+ defer p.deinit();
+ const pane = try p.setTestFile("saved\n");
+ pane.file.?.saved_revision = pane.file.?.revision -% 1; // modified
+ pane.file.?.saved_hash = 0; // edited: what it had is not what it has
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Exit"));
+ try std.testing.expect(!p.quit);
+ try std.testing.expect(std.mem.endsWith(u8, unsavedList(p), ": Modified\n\nExit again to discard\n"));
+ // Told once, and nothing edited since: the second Exit quits.
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Exit"));
+ try std.testing.expect(p.quit);
+}
+
+test "Exit over a ctl write or a click names every pane it asks about, a second only those edited since, and the next discards them all" {
+ for ([_]bool{ false, true }) |clicked| {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
+ defer p.deinit();
+ const first = try p.setTestFile("saved\n");
+ first.file.?.saved_revision = first.file.?.revision -% 1;
+ first.file.?.saved_hash = 0; // edited: what it had is not what it has
+ p.newScratchBelow(p.view().active);
+ const second = p.panes[p.view().active].?;
+ panes.File.setContent(p, &second.file.?, try std.testing.allocator.dupe(u8, &@as([120]u8, @splat('x'))));
+ try std.testing.expect(second.file.?.revision != second.file.?.saved_revision);
+ // A ctl write, or a click through exec (ctl.captured).
+ if (clicked) p.fs.capturing = true else p.fs.no_prompt = true;
+ defer p.fs.capturing = false;
+ defer p.fs.no_prompt = false;
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Exit"));
+ try std.testing.expect(!p.quit);
+ // Two: counted, never a list cut short; `unsaved` records name them.
+ try std.testing.expectEqualStrings("2 unsaved panes: Modified (Exit again to discard)", p.fs.failure[0..p.fs.failure_len]);
+ const log = p.fs.log.buf.items;
+ var rec: [64]u8 = undefined;
+ for ([_]*const Pane{ first, second }) |pane|
+ try std.testing.expect(std.mem.indexOf(u8, log, try std.fmt.bufPrint(&rec, "unsaved {d} ", .{pane.serial})) != null);
+ // The whole list stays in +Unsaved; the notice is short.
+ try std.testing.expect(std.mem.indexOf(u8, unsavedList(p), first.file.?.path) != null);
+ try std.testing.expect(std.mem.endsWith(u8, unsavedList(p), "\nExit again to discard\n"));
+ var noticed = false;
+ for (p.panes) |slot| if (slot) |pane| {
+ noticed = noticed or std.mem.eql(u8, pane.msg[0..pane.msg_len], "2 unsaved panes \u{2014} Exit again to discard");
+ };
+ try std.testing.expect(noticed);
+ // Edited since: only that one is named again (acme's rule).
+ p.fs.failure_len = 0;
+ panes.File.setContent(p, &second.file.?, try std.testing.allocator.dupe(u8, &@as([120]u8, @splat('y'))));
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Exit"));
+ try std.testing.expect(!p.quit);
+ const again = p.fs.failure[0..p.fs.failure_len];
+ try std.testing.expect(std.mem.indexOf(u8, again, first.file.?.path) == null);
+ // The one +Unsaved, filled again.
+ var kept: usize = 0;
+ for (p.panes) |slot| if (slot) |pane| if (pane.file) |f| if (f.output) |o| {
+ kept += @intFromBool(o.from == .unsaved);
+ };
+ try std.testing.expectEqual(@as(usize, 1), kept);
+ try std.testing.expect(std.mem.indexOf(u8, unsavedList(p), first.file.?.path) == null);
+ try std.testing.expect(std.mem.startsWith(u8, again, second.file.?.path));
+ p.fs.failure_len = 0;
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Exit"));
+ try std.testing.expect(p.quit);
+ }
+}
+
+test "Restore asks about unsaved text as Exit does, and restores when asked again" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
+ defer p.deinit();
+ const pane = try p.setTestFile("saved\n");
+ pane.file.?.saved_revision = pane.file.?.revision -% 1; // modified
+ pane.file.?.saved_hash = 0; // edited: what it had is not what it has
+ var line_buf: [4200]u8 = undefined;
+ const line = try testDump(&line_buf);
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, line));
+ try std.testing.expect(p.restore_req == null);
+ try std.testing.expect(std.mem.endsWith(u8, unsavedList(p), ": Modified\n\nRestore again to discard\n"));
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, line));
+ try std.testing.expectEqualStrings(line["Restore ".len..], p.restore_req.?);
+}
+
+test "a Restore of a dump that cannot be read says so, before the unsaved-text warning" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
+ defer p.deinit();
+ const pane = try p.setTestFile("saved\n");
+ pane.file.?.saved_revision = pane.file.?.revision -% 1; // modified
+ pane.file.?.saved_hash = 0; // edited: what it had is not what it has
+ p.fs.no_prompt = true;
+ defer p.fs.no_prompt = false;
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Restore /nope/missing.zon"));
+ try std.testing.expect(p.restore_req == null);
+ try std.testing.expectEqualStrings("Restore: /nope/missing.zon: no such file", p.fs.failure[0..p.fs.failure_len]);
+ // No warning spent: the Exit after it still asks.
+ try std.testing.expect(pane.discard_warned == null);
+}
+
+test "a Restore's warning is not an Exit's: each word is warned on its own" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
+ defer p.deinit();
+ const pane = try p.setTestFile("saved\n");
+ pane.file.?.saved_revision = pane.file.?.revision -% 1; // modified
+ pane.file.?.saved_hash = 0; // edited: what it had is not what it has
+ var line_buf: [4200]u8 = undefined;
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, try testDump(&line_buf)));
+ try std.testing.expect(p.restore_req == null);
+ // The Restore warned; an Exit after it has not been, and asks.
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Exit"));
+ try std.testing.expect(!p.quit);
+ try std.testing.expect(std.mem.endsWith(u8, unsavedList(p), ": Modified\n\nExit again to discard\n"));
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Exit"));
+ try std.testing.expect(p.quit);
+}
+
+test "Kill stops the commands pardes typed, bare all and by name those that match, and never quits" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 });
+ defer p.deinit();
+ while (p.nextEffect()) |_| {}
+ const term = p.view().active;
+ try std.testing.expect(p.panes[term].?.isTerminal());
+ const prompt = "\x1b]133;A;cl=line;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07";
+ p.update(.{ .output = .{ .pane = @intCast(term), .bytes = prompt } });
+ while (p.nextEffect()) |_| {}
+ // The host the core asks: how many it was asked to stop, and whether
+ // their shells run jobs in groups of their own.
+ const killed = struct {
+ var asked: usize = 0;
+ var job_control = true;
+ const vtable: pardes.Host.VTable = .{ .kill_job = answer };
+ fn answer(_: ?*anyopaque, _: u8) bool {
+ asked += 1;
+ return job_control;
+ }
+ fn count(pp: *Pardes, line: []const u8) usize {
+ asked = 0;
+ _ = pp.executeBuiltinLine(pp.view().active, line);
+ return asked;
+ }
+ };
+ p.host = .{ .vtable = &killed.vtable };
+ // Nothing running: nothing to stop, and never the shell; said.
+ try std.testing.expectEqual(@as(usize, 0), killed.count(p, "Kill"));
+ try std.testing.expectEqualStrings("Kill: nothing running", p.panes[term].?.msg[0..p.panes[term].?.msg_len]);
+ _ = exec.execute(p, term, "make -j8");
+ while (p.nextEffect()) |_| {}
+ // Typed but not started yet (no C mark): not running.
+ try std.testing.expectEqual(@as(usize, 0), killed.count(p, "Kill"));
+ p.update(.{ .output = .{ .pane = @intCast(term), .bytes = "\x1b]133;C;aid=pardes\x07" } });
+ while (p.nextEffect()) |_| {}
+ try std.testing.expectEqual(@as(usize, 0), killed.count(p, "Kill ls"));
+ try std.testing.expectEqual(@as(usize, 1), killed.count(p, "Kill ls make"));
+ try std.testing.expectEqual(@as(usize, 1), killed.count(p, "Kill"));
+ try std.testing.expect(!p.quit);
+ // With job control off there is no job apart from the shell: said, and
+ // over ctl the write fails with it.
+ killed.job_control = false;
+ p.fs.no_prompt = true;
+ try std.testing.expectEqual(@as(usize, 1), killed.count(p, "Kill"));
+ try std.testing.expectStringStartsWith(p.fs.failure[0..p.fs.failure_len], "Kill: no job to signal");
+ p.fs.no_prompt = false;
+ p.fs.failure_len = 0;
+ killed.job_control = true;
+ // Ended (a D mark): nothing to stop again.
+ p.update(.{ .output = .{ .pane = @intCast(term), .bytes = "\x1b]133;D;143;aid=pardes\x07" ++ prompt } });
+ while (p.nextEffect()) |_| {}
+ try std.testing.expectEqual(@as(usize, 0), killed.count(p, "Kill"));
+}
+
+test "Look does not announce itself on the message row; Del still does" {
+ const Builtin = registry.Builtin();
+ try std.testing.expect(!registry.announces(Builtin.Look));
+ try std.testing.expect(registry.announces(Builtin.Del));
+}
+
test "Exit and Restore name a modified +New scratch as well as files" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
defer p.deinit();