From 179409b9112ee9d9f858a124e0b109a46fe835c9 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 21 Dec 2011 13:47:21 +0000 Subject: [PATCH] =?UTF-8?q?*=20Add=20a=20test=20for=20referring=20to=20ano?= =?UTF-8?q?ther=20derivation's=20=E2=80=98drvPath=E2=80=99.=20=20This=20?= =?UTF-8?q?=20=20currently=20fails=20in=20read-only=20mode.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/multiple-outputs.nix | 10 ++++++++++ tests/multiple-outputs.sh | 20 +++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/tests/multiple-outputs.nix b/tests/multiple-outputs.nix index 7be96703d..9ce1f3dcf 100644 --- a/tests/multiple-outputs.nix +++ b/tests/multiple-outputs.nix @@ -32,6 +32,16 @@ rec { ''; }; + c = mkDerivation { + name = "multiple-outputs-c"; + drv = b.drvPath; + builder = builtins.toFile "builder.sh" + '' + mkdir $out + ln -s $drv $out/drv + ''; + }; + cyclic = (mkDerivation { name = "cyclic-outputs"; outputs = [ "a" "b" ]; diff --git a/tests/multiple-outputs.sh b/tests/multiple-outputs.sh index 8a7ae2236..aa328fdbc 100644 --- a/tests/multiple-outputs.sh +++ b/tests/multiple-outputs.sh @@ -1,18 +1,36 @@ source common.sh -echo "Testing multiple outputs..." +clearStore +# Test whether read-only evaluation works when referring to the +# ‘drvPath’ attribute. +echo "evaluating c..." +drvPath=$(nix-instantiate multiple-outputs.nix -A c --readonly-mode) + +# And check whether the resulting derivation explicitly depends on all +# outputs. +drvPath2=$(nix-instantiate multiple-outputs.nix -A c) +[ "$drvPath" = "$drvPath2" ] +grep -q 'multiple-outputs-a.drv",\["first","second"\]' $drvPath +grep -q 'multiple-outputs-b.drv",\["out"\]' $drvPath + +# Do a build of something that depends on a derivation with multiple +# outputs. +echo "building b..." outPath=$(nix-build multiple-outputs.nix -A b) echo "output path is $outPath" [ "$(cat "$outPath"/file)" = "success" ] # Make sure that nix-build works on derivations with multiple outputs. +echo "building a.first..." nix-build multiple-outputs.nix -A a.first # Cyclic outputs should be rejected. +echo "building cyclic..." if nix-build multiple-outputs.nix -A cyclic; then echo "Cyclic outputs incorrectly accepted!" exit 1 fi +echo "collecting garbage..." nix-store --gc