Skip to content

Commit 1fe2463

Browse files
tests/functional: add reject features test
1 parent 0fc68c3 commit 1fe2463

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

tests/functional/build-hook.nix

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,24 @@ let
4747
requiredSystemFeatures = ["baz"];
4848
};
4949

50+
input4 = mkDerivation {
51+
shell = busybox;
52+
name = "build-remote-input-4";
53+
buildCommand = ''
54+
echo hi-input3
55+
read x < ${input3}
56+
echo $x BAZ > $out
57+
'';
58+
rejectSystemFeatures = ["bar"];
59+
requiredSystemFeatures = ["foo"];
60+
};
61+
5062
in
5163

5264
mkDerivation {
5365
shell = busybox;
5466
name = "build-remote";
55-
passthru = { inherit input1 input2 input3; };
67+
passthru = { inherit input1 input2 input3 input4; };
5668
buildCommand =
5769
''
5870
read x < ${input1}

tests/functional/build-remote.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ builders=(
2323
"ssh://localhost?remote-store=$TEST_ROOT/machine1?system-features=$(join_by "%20" foo "${EXTRA_SYSTEM_FEATURES[@]}") - - 1 1 $(join_by "," foo "${EXTRA_SYSTEM_FEATURES[@]}")"
2424
"$TEST_ROOT/machine2 - - 1 1 $(join_by "," bar "${EXTRA_SYSTEM_FEATURES[@]}")"
2525
"ssh-ng://localhost?remote-store=$TEST_ROOT/machine3?system-features=$(join_by "%20" baz "${EXTRA_SYSTEM_FEATURES[@]}") - - 1 1 $(join_by "," baz "${EXTRA_SYSTEM_FEATURES[@]}")"
26+
"$TEST_ROOT/machine4 - - 1 1 $(join_by "," bar foo "${EXTRA_SYSTEM_FEATURES[@]}")"
2627
)
2728

2829
chmod -R +w "$TEST_ROOT/machine"* || true
@@ -70,6 +71,12 @@ echo "$output" | grepQuietInverse builder-build-remote-input-2.sh
7071
echo "$output" | grepQuiet builder-build-remote-input-3.sh
7172
unset output
7273

74+
# Ensure that input4 was built on store4 due to the required feature.
75+
output=$(nix path-info --store "$TEST_ROOT/machine4" --all)
76+
echo "$output" | grepQuietInverse builder-build-remote-input-1.sh
77+
echo "$output" | grepQuietInverse builder-build-remote-input-2.sh
78+
echo "$output" | grepQuietInverse builder-build-remote-input-3.sh
79+
unset output
7380

7481
for i in input1 input3; do
7582
nix log --store "$TEST_ROOT/machine0" --file "$file" --arg busybox "$busybox" "passthru.$i" | grep hi-$i

0 commit comments

Comments
 (0)