From b915a9abd3a2c9b961d1389587b36ce21173e3c0 Mon Sep 17 00:00:00 2001 From: regnat Date: Mon, 26 Oct 2020 09:57:34 +0100 Subject: [PATCH] Add a test for the substitution of CA derivations --- tests/content-addressed-remote-cache.sh | 20 ++++++++++++++++---- tests/local.mk | 1 + tests/push-to-store.sh | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tests/content-addressed-remote-cache.sh b/tests/content-addressed-remote-cache.sh index 2e46c269253..ab1ff3a20d2 100644 --- a/tests/content-addressed-remote-cache.sh +++ b/tests/content-addressed-remote-cache.sh @@ -4,11 +4,23 @@ source common.sh clearStore clearCache +clearCache + +export REMOTE_STORE=file://$cacheDir -commonFlags=(--experimental-features 'ca-derivations ca-references nix-command') +commonFlags=( \ + ./content-addressed.nix -A transitivelyDependentCA \ + --arg seed 1 \ + --experimental-features 'ca-derivations ca-references nix-command' \ + --no-out-link \ +) -drvPath=$(nix-instantiate "${commonFlags[@]}" ./content-addressed.nix -A transitivelyDependentCA --arg seed 1) -nix copy "${commonFlags[@]}" --to file://$cacheDir $drvPath\!out +nix-build "${commonFlags[@]}" --post-build-hook $PWD/push-to-store.sh clearStore -nix copy "${commonFlags[@]}" --from file://$cacheDir $drvPath\!out --no-require-sigs +# XXX: The `grep` call is a work around the fact that `-j0` currently doesn't +# take the possibility that drvs might be resolved into account, so would fail +# because Nix can't know *a priori* that everything is already in the binary +# cache +nix-build "${commonFlags[@]}" --no-require-sigs --substituters file://$cacheDir |& \ + (! grep -q 'Building a') diff --git a/tests/local.mk b/tests/local.mk index a1929f96d29..60b97b82935 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -35,6 +35,7 @@ nix_tests = \ recursive.sh \ describe-stores.sh \ flakes.sh \ + content-addressed-remote-cache.sh \ content-addressed.sh # parallel.sh # build-remote-content-addressed-fixed.sh \ diff --git a/tests/push-to-store.sh b/tests/push-to-store.sh index 82caaa3bb5c..f84a8a5656e 100755 --- a/tests/push-to-store.sh +++ b/tests/push-to-store.sh @@ -2,4 +2,4 @@ set -x echo Pushing "$OUTPUTS" to "$REMOTE_STORE" -printf "%s" "$OUTPUTS" | xargs -d: nix copy --to "$REMOTE_STORE" --no-require-sigs +printf "%s" "$OUTPUTS" | xargs nix copy --experimental-features 'ca-derivations ca-references nix-command' --to "$REMOTE_STORE" --no-require-sigs