Skip to content

Commit e6a26e6

Browse files
committed
fix: tests
1 parent f94016c commit e6a26e6

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

tests/extra/commands.lib.nix

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ let inherit (pkgs) lib; in
44
normalizeCommandsNested =
55
let
66
commands = (import ../../nix/commands/examples.nix { inherit pkgs; }).nested;
7-
check = (import ../../nix/commands/lib.nix { inherit pkgs; }).normalizeCommandsNested commands == [
7+
normalizedCommands = (import ../../nix/commands/lib.nix { inherit pkgs; }).normalizeCommandsNested commands;
8+
check = normalizedCommands == [
89
{
910
category = "category 1";
1011
command = null;
1112
expose = false;
1213
help = "[package] jq description";
14+
interpolate = null;
1315
name = "a.b.jq-1";
1416
package = pkgs.jq;
1517
prefix = "nix run .#";
@@ -19,6 +21,7 @@ let inherit (pkgs) lib; in
1921
command = null;
2022
expose = false;
2123
help = "[package] yq description";
24+
interpolate = null;
2225
name = "a.b.yq-1";
2326
package = pkgs.yq-go;
2427
prefix = "nix run ../#";
@@ -28,6 +31,7 @@ let inherit (pkgs) lib; in
2831
command = null;
2932
expose = false;
3033
help = "Portable command-line YAML processor";
34+
interpolate = null;
3135
name = "a.b.yq-2";
3236
package = pkgs.yq-go;
3337
prefix = "nix run .#";
@@ -37,6 +41,7 @@ let inherit (pkgs) lib; in
3741
command = null;
3842
expose = false;
3943
help = "a package manager for JavaScript";
44+
interpolate = null;
4045
name = "npm";
4146
package = pkgs.nodePackages.npm;
4247
prefix = "nix run .#";
@@ -46,6 +51,7 @@ let inherit (pkgs) lib; in
4651
command = null;
4752
expose = true;
4853
help = "GNU Find Utilities, the basic directory searching utilities of the GNU operating system";
54+
interpolate = null;
4955
name = "a.b.findutils";
5056
package = pkgs.findutils;
5157
prefix = "";
@@ -55,6 +61,7 @@ let inherit (pkgs) lib; in
5561
command = null;
5662
expose = false;
5763
help = "Command-line benchmarking tool";
64+
interpolate = null;
5865
name = "a.b.hyperfine";
5966
package = pkgs.hyperfine;
6067
prefix = "";
@@ -64,6 +71,7 @@ let inherit (pkgs) lib; in
6471
command = "${lib.getExe pkgs.gawk} $@";
6572
expose = true;
6673
help = "[command] run awk";
74+
interpolate = null;
6775
name = "a.b.awk";
6876
package = null;
6977
prefix = "";
@@ -73,6 +81,7 @@ let inherit (pkgs) lib; in
7381
command = "${lib.getExe pkgs.jq} $@";
7482
expose = true;
7583
help = "[command] run jq";
84+
interpolate = null;
7685
name = "a.b.jq-2";
7786
package = null;
7887
prefix = "";
@@ -82,6 +91,7 @@ let inherit (pkgs) lib; in
8291
command = ''printf "hello\n"'';
8392
expose = true;
8493
help = ''[command] print "hello"'';
94+
interpolate = null;
8595
name = "command with spaces";
8696
package = null;
8797
prefix = "";
@@ -91,6 +101,7 @@ let inherit (pkgs) lib; in
91101
command = null;
92102
expose = true;
93103
help = null;
104+
interpolate = null;
94105
name = pkgs.python3.name;
95106
package = pkgs.python3;
96107
prefix = "";
@@ -100,6 +111,7 @@ let inherit (pkgs) lib; in
100111
command = null;
101112
expose = true;
102113
help = "[package] vercel description";
114+
interpolate = null;
103115
name = pkgs.nodePackages.vercel.name;
104116
package = pkgs.nodePackages.vercel;
105117
prefix = "";
@@ -109,6 +121,7 @@ let inherit (pkgs) lib; in
109121
command = null;
110122
expose = true;
111123
help = null;
124+
interpolate = null;
112125
name = pkgs.nodePackages.yarn.name;
113126
package = pkgs.nodePackages.yarn;
114127
prefix = "";
@@ -118,6 +131,7 @@ let inherit (pkgs) lib; in
118131
command = null;
119132
expose = true;
120133
help = null;
134+
interpolate = null;
121135
name = null;
122136
package = pkgs.gnugrep;
123137
prefix = "";
@@ -127,6 +141,7 @@ let inherit (pkgs) lib; in
127141
command = null;
128142
expose = true;
129143
help = "run hello";
144+
interpolate = null;
130145
name = "run cowsay";
131146
package = pkgs.cowsay;
132147
prefix = "";
@@ -136,6 +151,7 @@ let inherit (pkgs) lib; in
136151
command = "${lib.getExe pkgs.perl} $@";
137152
expose = true;
138153
help = "run perl";
154+
interpolate = null;
139155
name = "run perl";
140156
package = null;
141157
prefix = "";
@@ -145,6 +161,7 @@ let inherit (pkgs) lib; in
145161
command = null;
146162
expose = true;
147163
help = "format Nix files";
164+
interpolate = null;
148165
name = "nix fmt";
149166
package = null;
150167
prefix = "";
@@ -154,6 +171,7 @@ let inherit (pkgs) lib; in
154171
command = null;
155172
expose = true;
156173
help = null;
174+
interpolate = null;
157175
name = null;
158176
package = pkgs.go;
159177
prefix = "";
@@ -163,6 +181,7 @@ let inherit (pkgs) lib; in
163181
command = null;
164182
expose = true;
165183
help = "[package] run hello ";
184+
interpolate = null;
166185
name = pkgs.hello.name;
167186
package = pkgs.hello;
168187
prefix = "";
@@ -172,6 +191,7 @@ let inherit (pkgs) lib; in
172191
command = null;
173192
expose = true;
174193
help = null;
194+
interpolate = null;
175195
name = pkgs.nixpkgs-fmt.name;
176196
package = pkgs.nixpkgs-fmt;
177197
prefix = "";

tests/extra/devshell.menu.interpolate.nix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
shell = devshell.mkShell {
66
devshell.menu.interpolate = true;
77
commands = [
8-
{ package = "hello"; help = "hello from '$PRJ_ROOT'!"; }
9-
{ package = "jq"; help = ''jq from '\$PRJ_ROOT'!''; }
8+
{ prefix = "hello"; help = ''hello from "$PRJ_ROOT"!''; }
9+
{ prefix = "hola"; help = ''hola from '\$PRJ_ROOT'!''; }
1010
];
1111
};
1212
in
1313
runTest "interpolate" { } ''
1414
# Check interpolation is enabled
15-
cat ${shell}/bin/menu | grep '<<DEVSHELL_MENU'
15+
eval ${shell}/bin/menu | grep "hello from \"$PRJ_ROOT\"!"
1616
1717
# Check escaped variable
18-
eval ${shell}/bin/menu | grep '\$PRJ_ROOT'
18+
eval ${shell}/bin/menu | grep 'hola from '\'''$PRJ_ROOT'\'
1919
'';
2020
}

0 commit comments

Comments
 (0)