Skip to content

Commit 207124b

Browse files
tests/functional: add reject features test
1 parent 1f826aa commit 207124b

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

tests/functional/build-hook.nix

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,31 @@ let
6969
requiredSystemFeatures = [ "baz" ];
7070
};
7171

72+
input4 = mkDerivation {
73+
shell = busybox;
74+
name = "build-remote-input-4";
75+
buildCommand = ''
76+
echo hi-input3
77+
read x < ${input3}
78+
echo $x BAZ > $out
79+
'';
80+
rejectSystemFeatures = [ "bar" ];
81+
requiredSystemFeatures = [ "foo" ];
82+
};
83+
7284
in
7385

7486
mkDerivation {
7587
shell = busybox;
7688
name = "build-remote";
77-
passthru = { inherit input1 input2 input3; };
89+
passthru = {
90+
inherit
91+
input1
92+
input2
93+
input3
94+
input4
95+
;
96+
};
7897
buildCommand = ''
7998
read x < ${input1}
8099
read y < ${input3}

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)