2011-09-14 07:59:29 +02:00
|
|
|
|
source common.sh
|
|
|
|
|
|
2011-12-21 14:47:21 +01:00
|
|
|
|
clearStore
|
2011-09-14 07:59:29 +02:00
|
|
|
|
|
2011-12-21 14:47:21 +01:00
|
|
|
|
# Test whether read-only evaluation works when referring to the
|
|
|
|
|
# ‘drvPath’ attribute.
|
|
|
|
|
echo "evaluating c..."
|
2011-12-21 19:19:05 +01:00
|
|
|
|
#drvPath=$(nix-instantiate multiple-outputs.nix -A c --readonly-mode)
|
2011-12-21 14:47:21 +01:00
|
|
|
|
|
|
|
|
|
# And check whether the resulting derivation explicitly depends on all
|
|
|
|
|
# outputs.
|
2011-12-21 19:19:05 +01:00
|
|
|
|
drvPath=$(nix-instantiate multiple-outputs.nix -A c)
|
|
|
|
|
#[ "$drvPath" = "$drvPath2" ]
|
2011-12-21 14:47:21 +01:00
|
|
|
|
grep -q 'multiple-outputs-a.drv",\["first","second"\]' $drvPath
|
|
|
|
|
grep -q 'multiple-outputs-b.drv",\["out"\]' $drvPath
|
|
|
|
|
|
2011-12-21 15:42:06 +01:00
|
|
|
|
# While we're at it, test the ‘unsafeDiscardOutputDependency’ primop.
|
2012-09-12 01:10:11 +02:00
|
|
|
|
outPath=$(nix-build multiple-outputs.nix -A d --no-out-link)
|
2011-12-21 15:42:06 +01:00
|
|
|
|
drvPath=$(cat $outPath/drv)
|
|
|
|
|
outPath=$(nix-store -q $drvPath)
|
|
|
|
|
! [ -e "$outPath" ]
|
|
|
|
|
|
2011-12-21 14:47:21 +01:00
|
|
|
|
# Do a build of something that depends on a derivation with multiple
|
|
|
|
|
# outputs.
|
|
|
|
|
echo "building b..."
|
2012-09-12 01:10:11 +02:00
|
|
|
|
outPath=$(nix-build multiple-outputs.nix -A b --no-out-link)
|
2011-09-14 07:59:29 +02:00
|
|
|
|
echo "output path is $outPath"
|
2011-12-20 18:01:02 +01:00
|
|
|
|
[ "$(cat "$outPath"/file)" = "success" ]
|
2011-12-20 18:08:43 +01:00
|
|
|
|
|
2012-09-12 01:10:11 +02:00
|
|
|
|
# Test nix-build on a derivation with multiple outputs.
|
|
|
|
|
nix-build multiple-outputs.nix -A a -o $TEST_ROOT/result
|
|
|
|
|
[ "$(cat $TEST_ROOT/result-first/file)" = "first" ]
|
|
|
|
|
[ "$(cat $TEST_ROOT/result-second/file)" = "second" ]
|
|
|
|
|
[ "$(cat $TEST_ROOT/result-second/link/file)" = "first" ]
|
|
|
|
|
hash1=$(nix-store -q --hash $TEST_ROOT/result-second)
|
|
|
|
|
|
|
|
|
|
# Delete one of the outputs and rebuild it. This will cause a hash
|
|
|
|
|
# rewrite.
|
|
|
|
|
nix-store --delete $TEST_ROOT/result-second --ignore-liveness
|
|
|
|
|
nix-build multiple-outputs.nix -A a -o $TEST_ROOT/result
|
|
|
|
|
[ "$(cat $TEST_ROOT/result-second/file)" = "second" ]
|
|
|
|
|
[ "$(cat $TEST_ROOT/result-second/link/file)" = "first" ]
|
|
|
|
|
hash2=$(nix-store -q --hash $TEST_ROOT/result-second)
|
|
|
|
|
[ "$hash1" = "$hash2" ]
|
|
|
|
|
|
2011-12-20 18:08:43 +01:00
|
|
|
|
# Make sure that nix-build works on derivations with multiple outputs.
|
2011-12-21 14:47:21 +01:00
|
|
|
|
echo "building a.first..."
|
2012-09-12 01:10:11 +02:00
|
|
|
|
nix-build multiple-outputs.nix -A a.first --no-out-link
|
2011-12-20 18:08:43 +01:00
|
|
|
|
|
|
|
|
|
# Cyclic outputs should be rejected.
|
2011-12-21 14:47:21 +01:00
|
|
|
|
echo "building cyclic..."
|
2012-09-12 01:10:11 +02:00
|
|
|
|
if nix-build multiple-outputs.nix -A cyclic --no-out-link; then
|
2011-12-20 18:08:43 +01:00
|
|
|
|
echo "Cyclic outputs incorrectly accepted!"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2011-12-21 14:47:21 +01:00
|
|
|
|
echo "collecting garbage..."
|
2012-09-13 00:49:35 +02:00
|
|
|
|
rm $TEST_ROOT/result*
|
|
|
|
|
nix-store --gc --option gc-keep-derivations true --option gc-keep-outputs true
|
|
|
|
|
nix-store --gc --print-roots
|