From 1fe2463e7f65f894f94ff2aacc33bca0a3c9ecd3 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 | 14 +++++++++++++- tests/functional/build-remote.sh | 7 +++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/functional/build-hook.nix b/tests/functional/build-hook.nix index 99a13aee483d..d1fda3802fa7 100644 --- a/tests/functional/build-hook.nix +++ b/tests/functional/build-hook.nix @@ -47,12 +47,24 @@ 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} 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