From 18057a7fbfc7e84f2af2c95fee9fc2fc9d3c988e Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Fri, 14 Feb 2025 12:27:52 -0800 Subject: [PATCH] tests/functional: add reject features test --- tests/functional/build-hook.nix | 21 ++++++++++++++++++++- tests/functional/build-remote.sh | 7 +++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/functional/build-hook.nix b/tests/functional/build-hook.nix index 45a2a84d6d4f..65328342ff81 100644 --- a/tests/functional/build-hook.nix +++ b/tests/functional/build-hook.nix @@ -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} diff --git a/tests/functional/build-remote.sh b/tests/functional/build-remote.sh index 3231341cbf6c..a74ef0070fa3 100644 --- a/tests/functional/build-remote.sh +++ b/tests/functional/build-remote.sh @@ -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 @@ -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