Skip to content

Commit

Permalink
tests/functional: add reject features test
Browse files Browse the repository at this point in the history
  • Loading branch information
RossComputerGuy committed Feb 19, 2025
1 parent 1f826aa commit 207124b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tests/functional/build-hook.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,31 @@ let
requiredSystemFeatures = [ "baz" ];
};

input4 = mkDerivation {
shell = busybox;
name = "build-remote-input-4";
buildCommand = ''
echo hi-input3
read x < ${input3}
echo $x BAZ > $out
'';
rejectSystemFeatures = [ "bar" ];
requiredSystemFeatures = [ "foo" ];
};

in

mkDerivation {
shell = busybox;
name = "build-remote";
passthru = { inherit input1 input2 input3; };
passthru = {
inherit
input1
input2
input3
input4
;
};
buildCommand = ''
read x < ${input1}
read y < ${input3}
Expand Down
7 changes: 7 additions & 0 deletions tests/functional/build-remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ builders=(
"ssh://localhost?remote-store=$TEST_ROOT/machine1?system-features=$(join_by "%20" foo "${EXTRA_SYSTEM_FEATURES[@]}") - - 1 1 $(join_by "," foo "${EXTRA_SYSTEM_FEATURES[@]}")"
"$TEST_ROOT/machine2 - - 1 1 $(join_by "," bar "${EXTRA_SYSTEM_FEATURES[@]}")"
"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[@]}")"
"$TEST_ROOT/machine4 - - 1 1 $(join_by "," bar foo "${EXTRA_SYSTEM_FEATURES[@]}")"
)

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

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

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

0 comments on commit 207124b

Please sign in to comment.