-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathflags-false.nix
More file actions
82 lines (70 loc) · 1.81 KB
/
flags-false.nix
File metadata and controls
82 lines (70 loc) · 1.81 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{
pkgs,
self,
}:
let
wrappedPackage = self.lib.wrapPackage {
inherit pkgs;
package = pkgs.hello;
flags = {
"--greeting" = "hi";
"--verbose" = true;
"--debug" = false;
"--trace" = false;
"--empty" = [ ];
"--output" = "file.txt";
};
};
in
pkgs.runCommand "flags-false-test" { } ''
echo "Testing that false and empty list flags are omitted..."
wrapperScript="${wrappedPackage}/bin/hello"
if [ ! -f "$wrapperScript" ]; then
echo "FAIL: Wrapper script not found"
exit 1
fi
# Check that included flags 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: '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
if ! grep -q "file.txt" "$wrapperScript"; then
echo "FAIL: 'file.txt' not found"
cat "$wrapperScript"
exit 1
fi
# Check that false and null flags are NOT present
if grep -q -- "--debug" "$wrapperScript"; then
echo "FAIL: --debug flag should be omitted (value was false)"
cat "$wrapperScript"
exit 1
fi
if grep -q -- "--trace" "$wrapperScript"; then
echo "FAIL: --trace flag should be omitted (value was false)"
cat "$wrapperScript"
exit 1
fi
if grep -q -- "--empty" "$wrapperScript"; then
echo "FAIL: --empty flag should be omitted (value was empty list)"
cat "$wrapperScript"
exit 1
fi
echo "SUCCESS: false and empty list flags correctly omitted"
touch $out
''