summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/snapshot.zig9
-rw-r--r--test/snapshots/builtins.golden8
-rw-r--r--test/snapshots/shellset.golden63
-rw-r--r--test/snapshots/shellset.snap43
4 files changed, 119 insertions, 4 deletions
diff --git a/test/snapshot.zig b/test/snapshot.zig
index 39350bee..36a5b20b 100644
--- a/test/snapshot.zig
+++ b/test/snapshot.zig
@@ -311,6 +311,15 @@ fn runScript(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const
// XDG directory that points outside this per-snapshot fake home.
const config_home = try std.fmt.allocPrintSentinel(arena, "{s}/.config", .{home}, 0);
_ = setenv("XDG_CONFIG_HOME", config_home, 1);
+ // ...and it is not empty: the DEFAULT shell is fish, whose prompt carries
+ // a hostname and whose greeting carries a version, so a golden taken
+ // against it would be a golden for this machine. Every script here runs
+ // bash — the .bashrc above pins its prompt to `$ ` — and the fish path is
+ // covered by shell_bin.zig's unit tests instead. This is an ordinary
+ // config file going through the ordinary startup-config path, so it also
+ // proves `Shell <name>` is dispatchable from one.
+ try mkdir(arena, config_home, false);
+ try eh.writeFile(try std.fmt.allocPrintSentinel(arena, "{s}/pardes", .{config_home}, 0), "Shell bash\n");
_ = setenv("TERM", "xterm-256color", 1);
_ = setenv("LC_ALL", "C", 1);
// a wall clock cannot live in a golden; everything that would print one
diff --git a/test/snapshots/builtins.golden b/test/snapshots/builtins.golden
index 36a7b2d9..08c701d7 100644
--- a/test/snapshots/builtins.golden
+++ b/test/snapshots/builtins.golden
@@ -153,7 +153,6 @@
|
|
| /tmp/pardes-snap/builtins/cwd/+Help New Del
-| 24 SPC l i Lspinfo
| 25 SPC l k Hover
| 26 SPC l r Rename
| 27 SPC l s Symbols
@@ -180,7 +179,8 @@
| 48 Look enter, right-click
| 49 Exec tab, middle-click
| 50 Theme
-| 51
+| 51 Shell
+| 52
== snap not-a-picker grid=120x60 cursor=7,58
|New Newcol Find Grep Help Tutor Dump NextColor Debug Kill
| /tmp/pardes-snap/builtins/cwd/notes.txt Save New Del
@@ -214,7 +214,6 @@
|
|
| /tmp/pardes-snap/builtins/cwd/+Help New Del
-| 24 SPC l i Lspinfo
| 25 SPC l k Hover
| 26 SPC l r Rename
| 27 SPC l s Symbols
@@ -241,7 +240,8 @@
| 48 Look enter, right-click
| 49 Exec tab, middle-click
| 50 Theme
-| 51
+| 51 Shell
+| 52
== snap window-group grid=120x60 cursor=7,32
|New Newcol Find Grep Help Tutor Dump NextColor Debug Kill
| /tmp/pardes-snap/builtins/cwd/notes.txt Save New Del
diff --git a/test/snapshots/shellset.golden b/test/snapshots/shellset.golden
new file mode 100644
index 00000000..330d21dc
--- /dev/null
+++ b/test/snapshots/shellset.golden
@@ -0,0 +1,63 @@
+== snap boot grid=90x20 cursor=7,2
+|New Newcol Find Grep Help Tutor Dump NextColor Debug Kill
+| /tmp/pardes-snap/shellset/cwd/cmd.txt Save New Del
+| 1 Shell zznosuchshell
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+== snap builtin-ran grid=90x20 cursor=25,2
+|New Newcol Find Grep Help Tutor Dump NextColor Debug Kill
+| /tmp/pardes-snap/shellset/cwd/cmd.txt Save New Del
+| 1 Shell zznosuchshell
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+== snap fallback-shell grid=90x20 cursor=49,4
+|New Newcol Find Grep Help Tutor Dump NextColor Debug Kill
+| /tmp/pardes-snap/shellset/cwd/cmd.txt Save /tmp/pardes-snap/shellset/cwd New Del
+| 1 Shell zznosuchshell
+| cmd.txt zmarkfile.txt
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
diff --git a/test/snapshots/shellset.snap b/test/snapshots/shellset.snap
new file mode 100644
index 00000000..193d8432
--- /dev/null
+++ b/test/snapshots/shellset.snap
@@ -0,0 +1,43 @@
+# The Shell builtin names the binary the NEXT terminal execs. What is pinned
+# here is the case that has to hold on a machine you did not set up: the name
+# resolves to nothing, and the pane opens anyway.
+#
+# That is not a corner — it is the DEFAULT's failure mode. pardes ships
+# `Shell fish` as the default, and a box without fish must still get a working
+# shell rather than a pane whose child dies at exec and shows one EOF. So the
+# lookup falls back, and this is the proof: a name nothing resolves to, and the
+# new pane still greets and lists like any other.
+#
+# The rest of the feature is unit-tested rather than pinned here, on purpose.
+# Which family a binary belongs to, what argv each one gets and where the
+# lookup searches are in shell_bin.zig's own tests; the fish end of it cannot
+# be a golden at all, because fish's prompt carries a hostname and its greeting
+# a version number. (Every script in this suite runs bash, pinned through an
+# ordinary config file the harness writes — see snapshot.zig.)
+file cmd.txt Shell zznosuchshell
+file zmarkfile.txt x
+start 20 90 cmd.txt
+wait 8000 Shell zznosuchshell
+stable 700 20000
+snap boot
+# execute the line the way you would run any command: select it, Tab. Nothing
+# on any machine is installed under that name, so the resolver runs out of
+# directories. (A file pane, so the line executed is the line you can see —
+# typing into a terminal's overlay would leave `gg`/`x` selecting its output.)
+key g g
+key x
+stable 400 5000
+key tab
+stable 700 15000
+# NOTHING happened on screen, and that is the assertion: a name the builtin
+# parser does not know is a command line, so it would have forked a terminal
+# for this directory and printed `Shell: command not found` into it (that is
+# cmdword.snap's contract). One pane, no error — `Shell` was consumed as a
+# builtin and its argument went with it.
+snap builtin-ran
+# a new terminal, which asks for a shell that is not there. It gets the
+# fallback: the pane greets, `ls` runs, and its output is on screen.
+key space c n
+wait 15000 zmarkfile.txt
+stable 700 20000
+snap fallback-shell