summaryrefslogtreecommitdiff
path: root/test/snapshot.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/snapshot.zig')
-rw-r--r--test/snapshot.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/snapshot.zig b/test/snapshot.zig
index 4344654c..19b65a02 100644
--- a/test/snapshot.zig
+++ b/test/snapshot.zig
@@ -28,6 +28,7 @@
// file <name> <content> create file in the script's cwd (before start)
// lines <name> <n> [tail] create file with n numbered lines, tail on each
// dirmk <name> create a subdirectory
+// run <shell...> run a command in the script's cwd (NOT in a pane)
// start <rows> <cols> [arg] fork the app in a pty (optional extra CLI arg)
// wait <ms> <needle...> pump until needle appears on the grid (fails hard)
// settle <ms> pump for a fixed duration
@@ -62,6 +63,7 @@ pub const std_options: std.Options = .{ .log_level = .err };
extern "c" fn setenv(name: [*:0]const u8, value: [*:0]const u8, overwrite: c_int) c_int;
extern "c" fn execvp(file: [*:0]const u8, argv: [*:null]const ?[*:0]const u8) c_int;
+extern "c" fn system(cmd: [*:0]const u8) c_int;
const SNAP_BASE = "/tmp/pardes-snap";
var trace_stable = false;
@@ -379,6 +381,14 @@ fn runScript(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const
try eh.writeFile(try arena.dupeZ(u8, name), ppm.items);
} else if (std.mem.eql(u8, cmd, "dirmk")) {
try mkdir(arena, tok.next() orelse return error.BadScript, false);
+ } else if (std.mem.eql(u8, cmd, "run")) {
+ // A writer that is NOT a pardes pane. `file` mid-script is already
+ // one, but it cannot express the rename-over that is how a
+ // formatter actually replaces a file — and the difference is a
+ // different inotify event. This runs in the script's cwd, as a
+ // child of the RUNNER, so nothing it does reaches the app's ptys:
+ // whatever the app then shows, it woke up for by itself.
+ if (system(try arena.dupeZ(u8, tok.rest())) != 0) return error.RunFailed;
} else if (std.mem.eql(u8, cmd, "start")) {
const rows = try std.fmt.parseInt(u16, tok.next() orelse return error.BadScript, 10);
const cols = try std.fmt.parseInt(u16, tok.next() orelse return error.BadScript, 10);