-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathflags-empty-list.nix
More file actions
62 lines (53 loc) · 1.32 KB
/
flags-empty-list.nix
File metadata and controls
62 lines (53 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{
pkgs,
self,
}:
let
wrappedPackage = self.lib.wrapPackage {
inherit pkgs;
package = pkgs.hello;
flags = {
"--greeting" = "hi";
"--verbose" = true;
"--empty" = [ ];
"--output" = "file.txt";
};
};
in
pkgs.runCommand "flags-empty-list-test" { } ''
echo "Testing flags with empty list..."
wrapperScript="${wrappedPackage}/bin/hello"
if [ ! -f "$wrapperScript" ]; then
echo "FAIL: Wrapper script not found"
exit 1
fi
# Check that flags with non-empty values are present
if ! grep -q -- "--greeting" "$wrapperScript"; then
echo "FAIL: --greeting flag not found"
cat "$wrapperScript"
exit 1
fi
if ! grep -q "hi" "$wrapperScript"; then
echo "FAIL: greeting value 'hi' not found"
cat "$wrapperScript"
exit 1
fi
if ! grep -q -- "--verbose" "$wrapperScript"; then
echo "FAIL: --verbose flag not found"
cat "$wrapperScript"
exit 1
fi
if ! grep -q -- "--output" "$wrapperScript"; then
echo "FAIL: --output flag not found"
cat "$wrapperScript"
exit 1
fi
# Check that empty list flag is NOT present
if grep -q -- "--empty" "$wrapperScript"; then
echo "FAIL: --empty flag should be omitted (value was empty list)"
cat "$wrapperScript"
exit 1
fi
echo "SUCCESS: empty list flags correctly omitted"
touch $out
''