* Refactoring: remove unnecessary variables from the tests.

This commit is contained in:
Eelco Dolstra 2011-10-10 21:32:34 +00:00
parent cd6d02c366
commit 8af7d766f0
33 changed files with 220 additions and 235 deletions

View file

@ -1,9 +1,9 @@
source common.sh source common.sh
path1=$($nixstore --add ./dummy) path1=$(nix-store --add ./dummy)
echo $path1 echo $path1
path2=$($nixstore --add-fixed sha256 --recursive ./dummy) path2=$(nix-store --add-fixed sha256 --recursive ./dummy)
echo $path2 echo $path2
if test "$path1" != "$path2"; then if test "$path1" != "$path2"; then
@ -11,18 +11,18 @@ if test "$path1" != "$path2"; then
exit 1 exit 1
fi fi
path3=$($nixstore --add-fixed sha256 ./dummy) path3=$(nix-store --add-fixed sha256 ./dummy)
echo $path3 echo $path3
test "$path1" != "$path3" || exit 1 test "$path1" != "$path3" || exit 1
path4=$($nixstore --add-fixed sha1 --recursive ./dummy) path4=$(nix-store --add-fixed sha1 --recursive ./dummy)
echo $path4 echo $path4
test "$path1" != "$path4" || exit 1 test "$path1" != "$path4" || exit 1
hash1=$($nixstore -q --hash $path1) hash1=$(nix-store -q --hash $path1)
echo $hash1 echo $hash1
hash2=$($nixhash --type sha256 --base32 ./dummy) hash2=$(nix-hash --type sha256 --base32 ./dummy)
echo $hash2 echo $hash2
test "$hash1" = "sha256:$hash2" test "$hash1" = "sha256:$hash2"

View file

@ -8,12 +8,12 @@ RESULT=$TEST_ROOT/result
# Build version 1 and 2 of the "foo" package. # Build version 1 and 2 of the "foo" package.
nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest1 \ nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest1 \
$($nixbuild -o $RESULT binary-patching.nix --arg version 1) $(nix-build -o $RESULT binary-patching.nix --arg version 1)
out2=$($nixbuild -o $RESULT binary-patching.nix --arg version 2) out2=$(nix-build -o $RESULT binary-patching.nix --arg version 2)
nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest2 $out2 nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest2 $out2
out3=$($nixbuild -o $RESULT binary-patching.nix --arg version 3) out3=$(nix-build -o $RESULT binary-patching.nix --arg version 3)
nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest3 $out3 nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest3 $out3
rm $RESULT rm $RESULT
@ -28,19 +28,19 @@ nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \
grep -q "patch {" $TEST_ROOT/manifest3 grep -q "patch {" $TEST_ROOT/manifest3
# Get rid of versions 2 and 3. # Get rid of versions 2 and 3.
$nixstore --delete $out2 $out3 nix-store --delete $out2 $out3
# Pull the manifest containing the patches. # Pull the manifest containing the patches.
clearManifests clearManifests
$NIX_BIN_DIR/nix-pull file://$TEST_ROOT/manifest3 nix-pull file://$TEST_ROOT/manifest3
# Make sure that the download size prediction uses the patches rather # Make sure that the download size prediction uses the patches rather
# than the full download. # than the full download.
$nixbuild -o $RESULT binary-patching.nix --arg version 3 --dry-run 2>&1 | grep -q "0.01 MiB" nix-build -o $RESULT binary-patching.nix --arg version 3 --dry-run 2>&1 | grep -q "0.01 MiB"
# Now rebuild it. This should use the two patches generated above. # Now rebuild it. This should use the two patches generated above.
rm -f $TEST_ROOT/var/log/nix/downloads rm -f $TEST_ROOT/var/log/nix/downloads
$nixbuild -o $RESULT binary-patching.nix --arg version 3 nix-build -o $RESULT binary-patching.nix --arg version 3
rm $RESULT rm $RESULT
[ "$(grep ' patch ' $TEST_ROOT/var/log/nix/downloads | wc -l)" -eq 2 ] [ "$(grep ' patch ' $TEST_ROOT/var/log/nix/downloads | wc -l)" -eq 2 ]
@ -50,9 +50,9 @@ nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \
# Rebuild version 3. This should use the direct patch rather than the # Rebuild version 3. This should use the direct patch rather than the
# sequence of two patches. # sequence of two patches.
$nixstore --delete $out2 $out3 nix-store --delete $out2 $out3
clearManifests clearManifests
rm $TEST_ROOT/var/log/nix/downloads rm $TEST_ROOT/var/log/nix/downloads
$NIX_BIN_DIR/nix-pull file://$TEST_ROOT/manifest3 nix-pull file://$TEST_ROOT/manifest3
$nixbuild -o $RESULT binary-patching.nix --arg version 3 nix-build -o $RESULT binary-patching.nix --arg version 3
[ "$(grep ' patch ' $TEST_ROOT/var/log/nix/downloads | wc -l)" -eq 1 ] [ "$(grep ' patch ' $TEST_ROOT/var/log/nix/downloads | wc -l)" -eq 1 ]

View file

@ -2,7 +2,7 @@ source common.sh
export NIX_BUILD_HOOK="build-hook.hook.sh" export NIX_BUILD_HOOK="build-hook.hook.sh"
outPath=$($nixbuild build-hook.nix) outPath=$(nix-build build-hook.nix)
echo "output path is $outPath" echo "output path is $outPath"

View file

@ -4,33 +4,33 @@ set -x
RESULT=$TEST_ROOT/result RESULT=$TEST_ROOT/result
dep=$($nixbuild -o $RESULT check-refs.nix -A dep) dep=$(nix-build -o $RESULT check-refs.nix -A dep)
# test1 references dep, not itself. # test1 references dep, not itself.
test1=$($nixbuild -o $RESULT check-refs.nix -A test1) test1=$(nix-build -o $RESULT check-refs.nix -A test1)
! $nixstore -q --references $test1 | grep -q $test1 ! nix-store -q --references $test1 | grep -q $test1
$nixstore -q --references $test1 | grep -q $dep nix-store -q --references $test1 | grep -q $dep
# test2 references src, not itself nor dep. # test2 references src, not itself nor dep.
test2=$($nixbuild -o $RESULT check-refs.nix -A test2) test2=$(nix-build -o $RESULT check-refs.nix -A test2)
! $nixstore -q --references $test2 | grep -q $test2 ! nix-store -q --references $test2 | grep -q $test2
! $nixstore -q --references $test2 | grep -q $dep ! nix-store -q --references $test2 | grep -q $dep
$nixstore -q --references $test2 | grep -q aux-ref nix-store -q --references $test2 | grep -q aux-ref
# test3 should fail (unallowed ref). # test3 should fail (unallowed ref).
! $nixbuild -o $RESULT check-refs.nix -A test3 ! nix-build -o $RESULT check-refs.nix -A test3
# test4 should succeed. # test4 should succeed.
$nixbuild -o $RESULT check-refs.nix -A test4 nix-build -o $RESULT check-refs.nix -A test4
# test5 should succeed. # test5 should succeed.
$nixbuild -o $RESULT check-refs.nix -A test5 nix-build -o $RESULT check-refs.nix -A test5
# test6 should fail (unallowed self-ref). # test6 should fail (unallowed self-ref).
! $nixbuild -o $RESULT check-refs.nix -A test6 ! nix-build -o $RESULT check-refs.nix -A test6
# test7 should succeed (allowed self-ref). # test7 should succeed (allowed self-ref).
$nixbuild -o $RESULT check-refs.nix -A test7 nix-build -o $RESULT check-refs.nix -A test7
# test8 should fail (toFile depending on derivation output). # test8 should fail (toFile depending on derivation output).
! $nixbuild -o $RESULT check-refs.nix -A test8 ! nix-build -o $RESULT check-refs.nix -A test8

View file

@ -47,13 +47,6 @@ export SHELL="@shell@"
export version=@version@ export version=@version@
export system=@system@ export system=@system@
export nixinstantiate=$TOP/src/nix-instantiate/nix-instantiate
export nixstore=$TOP/src/nix-store/nix-store
export nixenv=$TOP/src/nix-env/nix-env
export nixhash=$TOP/src/nix-hash/nix-hash
export nixworker=$TOP/src/nix-worker/nix-worker
export nixbuild=$NIX_BIN_DIR/nix-build
readLink() { readLink() {
ls -l "$1" | sed 's/.*->\ //' ls -l "$1" | sed 's/.*->\ //'
} }
@ -70,7 +63,7 @@ clearStore() {
mkdir "$NIX_STORE_DIR" mkdir "$NIX_STORE_DIR"
rm -rf "$NIX_DB_DIR" rm -rf "$NIX_DB_DIR"
mkdir "$NIX_DB_DIR" mkdir "$NIX_DB_DIR"
$nixstore --init nix-store --init
clearProfiles clearProfiles
rm -f "$NIX_STATE_DIR"/gcroots/auto/* rm -f "$NIX_STATE_DIR"/gcroots/auto/*
rm -f "$NIX_STATE_DIR"/gcroots/ref rm -f "$NIX_STATE_DIR"/gcroots/ref
@ -81,7 +74,7 @@ clearManifests() {
} }
startDaemon() { startDaemon() {
$nixworker --daemon & nix-worker --daemon &
pidDaemon=$! pidDaemon=$!
trap "kill -9 $pidDaemon" EXIT trap "kill -9 $pidDaemon" EXIT
export NIX_REMOTE=daemon export NIX_REMOTE=daemon

View file

@ -2,36 +2,36 @@ source common.sh
clearStore clearStore
drvPath=$($nixinstantiate dependencies.nix) drvPath=$(nix-instantiate dependencies.nix)
echo "derivation is $drvPath" echo "derivation is $drvPath"
$nixstore -q --tree "$drvPath" | grep ' +---.*builder1.sh' nix-store -q --tree "$drvPath" | grep ' +---.*builder1.sh'
# Test Graphviz graph generation. # Test Graphviz graph generation.
$nixstore -q --graph "$drvPath" > $TEST_ROOT/graph nix-store -q --graph "$drvPath" > $TEST_ROOT/graph
if test -n "$dot"; then if test -n "$dot"; then
# Does it parse? # Does it parse?
$dot < $TEST_ROOT/graph $dot < $TEST_ROOT/graph
fi fi
outPath=$($nixstore -rvv "$drvPath") || fail "build failed" outPath=$(nix-store -rvv "$drvPath") || fail "build failed"
# Test Graphviz graph generation. # Test Graphviz graph generation.
$nixstore -q --graph "$outPath" > $TEST_ROOT/graph nix-store -q --graph "$outPath" > $TEST_ROOT/graph
if test -n "$dot"; then if test -n "$dot"; then
# Does it parse? # Does it parse?
$dot < $TEST_ROOT/graph $dot < $TEST_ROOT/graph
fi fi
$nixstore -q --tree "$outPath" | grep '+---.*dependencies-input-2' nix-store -q --tree "$outPath" | grep '+---.*dependencies-input-2'
echo "output path is $outPath" echo "output path is $outPath"
text=$(cat "$outPath"/foobar) text=$(cat "$outPath"/foobar)
if test "$text" != "FOOBAR"; then exit 1; fi if test "$text" != "FOOBAR"; then exit 1; fi
deps=$($nixstore -quR "$drvPath") deps=$(nix-store -quR "$drvPath")
echo "output closure contains $deps" echo "output closure contains $deps"
@ -45,8 +45,8 @@ if echo "$deps" | grep -q "dependencies-input-1"; then exit 1; fi
input2OutPath=$(echo "$deps" | grep "dependencies-input-2") input2OutPath=$(echo "$deps" | grep "dependencies-input-2")
# The referrers closure of input-2 should include outPath. # The referrers closure of input-2 should include outPath.
$nixstore -q --referrers-closure "$input2OutPath" | grep "$outPath" nix-store -q --referrers-closure "$input2OutPath" | grep "$outPath"
# Check that the derivers are set properly. # Check that the derivers are set properly.
test $($nixstore -q --deriver "$outPath") = "$drvPath" test $(nix-store -q --deriver "$outPath") = "$drvPath"
$nixstore -q --deriver "$input2OutPath" | grep -q -- "-input-2.drv" nix-store -q --deriver "$input2OutPath" | grep -q -- "-input-2.drv"

View file

@ -4,23 +4,23 @@ clearStore
clearProfiles clearProfiles
checkRef() { checkRef() {
$nixstore -q --references ./result | grep -q "$1" || fail "missing reference $1" nix-store -q --references ./result | grep -q "$1" || fail "missing reference $1"
} }
# Test the export of the runtime dependency graph. # Test the export of the runtime dependency graph.
outPath=$($nixbuild ./export-graph.nix -A runtimeGraph) outPath=$(nix-build ./export-graph.nix -A runtimeGraph)
test $($nixstore -q --references ./result | wc -l) = 2 || fail "bad nr of references" test $(nix-store -q --references ./result | wc -l) = 2 || fail "bad nr of references"
checkRef input-2 checkRef input-2
for i in $(cat $outPath); do checkRef $i; done for i in $(cat $outPath); do checkRef $i; done
# Test the export of the build-time dependency graph. # Test the export of the build-time dependency graph.
$nixstore --gc # should force rebuild of input-1 nix-store --gc # should force rebuild of input-1
outPath=$($nixbuild ./export-graph.nix -A buildGraph) outPath=$(nix-build ./export-graph.nix -A buildGraph)
checkRef input-1 checkRef input-1
checkRef input-1.drv checkRef input-1.drv

View file

@ -2,16 +2,16 @@ source common.sh
clearStore clearStore
outPath=$($nixbuild dependencies.nix) outPath=$(nix-build dependencies.nix)
$nixstore --export $outPath > $TEST_ROOT/exp nix-store --export $outPath > $TEST_ROOT/exp
$nixstore --export $($nixstore -qR $outPath) > $TEST_ROOT/exp_all nix-store --export $(nix-store -qR $outPath) > $TEST_ROOT/exp_all
clearStore clearStore
if $nixstore --import < $TEST_ROOT/exp; then if nix-store --import < $TEST_ROOT/exp; then
echo "importing a non-closure should fail" echo "importing a non-closure should fail"
exit 1 exit 1
fi fi
@ -19,13 +19,13 @@ fi
clearStore clearStore
$nixstore --import < $TEST_ROOT/exp_all nix-store --import < $TEST_ROOT/exp_all
$nixstore --export $($nixstore -qR $outPath) > $TEST_ROOT/exp_all2 nix-store --export $(nix-store -qR $outPath) > $TEST_ROOT/exp_all2
clearStore clearStore
# Regression test: the derivers in exp_all2 are empty, which shouldn't # Regression test: the derivers in exp_all2 are empty, which shouldn't
# cause a failure. # cause a failure.
$nixstore --import < $TEST_ROOT/exp_all2 nix-store --import < $TEST_ROOT/exp_all2

View file

@ -2,19 +2,19 @@ source common.sh
clearStore clearStore
drvPath=$($nixinstantiate simple.nix) drvPath=$(nix-instantiate simple.nix)
echo "derivation is $drvPath" echo "derivation is $drvPath"
outPath=$($nixstore -q --fallback "$drvPath") outPath=$(nix-store -q --fallback "$drvPath")
echo "output path is $outPath" echo "output path is $outPath"
# Build with a substitute that fails. This should fail. # Build with a substitute that fails. This should fail.
export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh
if $nixstore -r "$drvPath"; then echo unexpected fallback; exit 1; fi if nix-store -r "$drvPath"; then echo unexpected fallback; exit 1; fi
# Build with a substitute that fails. This should fall back to a source build. # Build with a substitute that fails. This should fall back to a source build.
export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh
$nixstore -r --fallback "$drvPath" nix-store -r --fallback "$drvPath"
text=$(cat "$outPath"/hello) text=$(cat "$outPath"/hello)
if test "$text" != "Hello World!"; then exit 1; fi if test "$text" != "Hello World!"; then exit 1; fi

View file

@ -10,7 +10,7 @@ touch $TEST_ROOT/filterin/bak
touch $TEST_ROOT/filterin/bla.c.bak touch $TEST_ROOT/filterin/bla.c.bak
ln -s xyzzy $TEST_ROOT/filterin/link ln -s xyzzy $TEST_ROOT/filterin/link
$NIX_BIN_DIR/nix-build ./filter-source.nix -o $TEST_ROOT/filterout nix-build ./filter-source.nix -o $TEST_ROOT/filterout
set -x set -x
test ! -e $TEST_ROOT/filterout/foo/bar test ! -e $TEST_ROOT/filterout/foo/bar

View file

@ -6,31 +6,31 @@ export IMPURE_VAR1=foo
export IMPURE_VAR2=bar export IMPURE_VAR2=bar
echo 'testing good...' echo 'testing good...'
$nixbuild fixed.nix -A good nix-build fixed.nix -A good
echo 'testing good2...' echo 'testing good2...'
$nixbuild fixed.nix -A good2 nix-build fixed.nix -A good2
echo 'testing bad...' echo 'testing bad...'
$nixbuild fixed.nix -A bad && fail "should fail" nix-build fixed.nix -A bad && fail "should fail"
echo 'testing reallyBad...' echo 'testing reallyBad...'
$nixinstantiate fixed.nix -A reallyBad && fail "should fail" nix-instantiate fixed.nix -A reallyBad && fail "should fail"
# While we're at it, check attribute selection a bit more. # While we're at it, check attribute selection a bit more.
echo 'testing attribute selection...' echo 'testing attribute selection...'
test $($nixinstantiate fixed.nix -A good.1 | wc -l) = 1 test $(nix-instantiate fixed.nix -A good.1 | wc -l) = 1
# Test parallel builds of derivations that produce the same output. # Test parallel builds of derivations that produce the same output.
# Only one should run at the same time. # Only one should run at the same time.
echo 'testing parallelSame...' echo 'testing parallelSame...'
clearStore clearStore
$nixbuild fixed.nix -A parallelSame -j2 nix-build fixed.nix -A parallelSame -j2
# Fixed-output derivations with a recursive SHA-256 hash should # Fixed-output derivations with a recursive SHA-256 hash should
# produce the same path as "nix-store --add". # produce the same path as "nix-store --add".
echo 'testing sameAsAdd...' echo 'testing sameAsAdd...'
out=$($nixbuild fixed.nix -A sameAsAdd) out=$(nix-build fixed.nix -A sameAsAdd)
# This is what fixed.builder2 produces... # This is what fixed.builder2 produces...
rm -rf $TEST_ROOT/fixed rm -rf $TEST_ROOT/fixed
@ -39,14 +39,14 @@ mkdir $TEST_ROOT/fixed/bla
echo "Hello World!" > $TEST_ROOT/fixed/foo echo "Hello World!" > $TEST_ROOT/fixed/foo
ln -s foo $TEST_ROOT/fixed/bar ln -s foo $TEST_ROOT/fixed/bar
out2=$($nixstore --add $TEST_ROOT/fixed) out2=$(nix-store --add $TEST_ROOT/fixed)
echo $out2 echo $out2
test "$out" = "$out2" || exit 1 test "$out" = "$out2" || exit 1
out3=$($nixstore --add-fixed --recursive sha256 $TEST_ROOT/fixed) out3=$(nix-store --add-fixed --recursive sha256 $TEST_ROOT/fixed)
echo $out3 echo $out3
test "$out" = "$out3" || exit 1 test "$out" = "$out3" || exit 1
out4=$($nixstore --print-fixed-path --recursive sha256 "1ixr6yd3297ciyp9im522dfxpqbkhcw0pylkb2aab915278fqaik" fixed) out4=$(nix-store --print-fixed-path --recursive sha256 "1ixr6yd3297ciyp9im522dfxpqbkhcw0pylkb2aab915278fqaik" fixed)
echo $out4 echo $out4
test "$out" = "$out4" || exit 1 test "$out" = "$out4" || exit 1

View file

@ -2,14 +2,14 @@ source common.sh
clearStore clearStore
drvPath1=$($nixinstantiate gc-concurrent.nix -A test1) drvPath1=$(nix-instantiate gc-concurrent.nix -A test1)
outPath1=$($nixstore -q $drvPath1) outPath1=$(nix-store -q $drvPath1)
drvPath2=$($nixinstantiate gc-concurrent.nix -A test2) drvPath2=$(nix-instantiate gc-concurrent.nix -A test2)
outPath2=$($nixstore -q $drvPath2) outPath2=$(nix-store -q $drvPath2)
drvPath3=$($nixinstantiate simple.nix) drvPath3=$(nix-instantiate simple.nix)
outPath3=$($nixstore -r $drvPath3) outPath3=$(nix-store -r $drvPath3)
! test -e $outPath3.lock ! test -e $outPath3.lock
touch $outPath3.lock touch $outPath3.lock
@ -19,16 +19,16 @@ ln -s $drvPath2 "$NIX_STATE_DIR"/gcroots/foo
ln -s $outPath3 "$NIX_STATE_DIR"/gcroots/foo2 ln -s $outPath3 "$NIX_STATE_DIR"/gcroots/foo2
# Start build #1 in the background. It starts immediately. # Start build #1 in the background. It starts immediately.
$nixstore -rvv "$drvPath1" & nix-store -rvv "$drvPath1" &
pid1=$! pid1=$!
# Start build #2 in the background after 10 seconds. # Start build #2 in the background after 10 seconds.
(sleep 10 && $nixstore -rvv "$drvPath2") & (sleep 10 && nix-store -rvv "$drvPath2") &
pid2=$! pid2=$!
# Run the garbage collector while the build is running. # Run the garbage collector while the build is running.
sleep 6 sleep 6
$NIX_BIN_DIR/nix-collect-garbage nix-collect-garbage
# Wait for build #1/#2 to finish. # Wait for build #1/#2 to finish.
echo waiting for pid $pid1 to finish... echo waiting for pid $pid1 to finish...
@ -53,6 +53,6 @@ rm -f "$NIX_STATE_DIR"/gcroots/foo*
! test -e $outPath3.lock ! test -e $outPath3.lock
# If we run the collector now, it should delete outPath1/2. # If we run the collector now, it should delete outPath1/2.
$NIX_BIN_DIR/nix-collect-garbage nix-collect-garbage
! test -e $outPath1 ! test -e $outPath1
! test -e $outPath2 ! test -e $outPath2

View file

@ -12,9 +12,9 @@ set -m # enable job control, needed for kill
profiles="$NIX_STATE_DIR"/profiles profiles="$NIX_STATE_DIR"/profiles
rm -f $profiles/* rm -f $profiles/*
$nixenv -p $profiles/test -f ./gc-runtime.nix -i gc-runtime nix-env -p $profiles/test -f ./gc-runtime.nix -i gc-runtime
outPath=$($nixenv -p $profiles/test -q --no-name --out-path gc-runtime) outPath=$(nix-env -p $profiles/test -q --no-name --out-path gc-runtime)
echo $outPath echo $outPath
echo "backgrounding program..." echo "backgrounding program..."
@ -23,12 +23,12 @@ sleep 2 # hack - wait for the program to get started
child=$! child=$!
echo PID=$child echo PID=$child
$nixenv -p $profiles/test -e gc-runtime nix-env -p $profiles/test -e gc-runtime
$nixenv -p $profiles/test --delete-generations old nix-env -p $profiles/test --delete-generations old
cp $TOP/scripts/find-runtime-roots.pl $TEST_ROOT/foo.pl cp $TOP/scripts/find-runtime-roots.pl $TEST_ROOT/foo.pl
chmod +x $TEST_ROOT/foo.pl chmod +x $TEST_ROOT/foo.pl
NIX_ROOT_FINDER=$TEST_ROOT/foo.pl $nixstore --gc NIX_ROOT_FINDER=$TEST_ROOT/foo.pl nix-store --gc
kill -- -$child kill -- -$child

View file

@ -1,27 +1,27 @@
source common.sh source common.sh
drvPath=$($nixinstantiate dependencies.nix) drvPath=$(nix-instantiate dependencies.nix)
outPath=$($nixstore -rvv "$drvPath") outPath=$(nix-store -rvv "$drvPath")
# Set a GC root. # Set a GC root.
rm -f "$NIX_STATE_DIR"/gcroots/foo rm -f "$NIX_STATE_DIR"/gcroots/foo
ln -sf $outPath "$NIX_STATE_DIR"/gcroots/foo ln -sf $outPath "$NIX_STATE_DIR"/gcroots/foo
$nixstore --gc --print-roots | grep $outPath nix-store --gc --print-roots | grep $outPath
$nixstore --gc --print-live | grep $outPath nix-store --gc --print-live | grep $outPath
$nixstore --gc --print-dead | grep $drvPath nix-store --gc --print-dead | grep $drvPath
if $nixstore --gc --print-dead | grep $outPath; then false; fi if nix-store --gc --print-dead | grep $outPath; then false; fi
$nixstore --gc --print-dead nix-store --gc --print-dead
inUse=$(readLink $outPath/input-2) inUse=$(readLink $outPath/input-2)
if $nixstore --delete $inUse; then false; fi if nix-store --delete $inUse; then false; fi
test -e $inUse test -e $inUse
if $nixstore --delete $outPath; then false; fi if nix-store --delete $outPath; then false; fi
test -e $outPath test -e $outPath
$NIX_BIN_DIR/nix-collect-garbage nix-collect-garbage
# Check that the root and its dependencies haven't been deleted. # Check that the root and its dependencies haven't been deleted.
cat $outPath/foobar cat $outPath/foobar
@ -32,7 +32,7 @@ if test -e $drvPath; then false; fi
rm "$NIX_STATE_DIR"/gcroots/foo rm "$NIX_STATE_DIR"/gcroots/foo
$NIX_BIN_DIR/nix-collect-garbage nix-collect-garbage
# Check that the output has been GC'd. # Check that the output has been GC'd.
if test -e $outPath/foobar; then false; fi if test -e $outPath/foobar; then false; fi

View file

@ -2,7 +2,7 @@ source common.sh
try () { try () {
printf "%s" "$2" > $TEST_ROOT/vector printf "%s" "$2" > $TEST_ROOT/vector
hash=$($nixhash $EXTRA --flat --type "$1" $TEST_ROOT/vector) hash=$(nix-hash $EXTRA --flat --type "$1" $TEST_ROOT/vector)
if test "$hash" != "$3"; then if test "$hash" != "$3"; then
echo "hash $1, expected $3, got $hash" echo "hash $1, expected $3, got $hash"
exit 1 exit 1
@ -28,7 +28,7 @@ try sha256 "abc" "1b8m03r63zqhnjf7l5wnldhh7c134ap5vpj0850ymkq1iyzicy5s"
EXTRA= EXTRA=
try2 () { try2 () {
hash=$($nixhash --type "$1" $TEST_ROOT/hash-path) hash=$(nix-hash --type "$1" $TEST_ROOT/hash-path)
if test "$hash" != "$2"; then if test "$hash" != "$2"; then
echo "hash $1, expected $2, got $hash" echo "hash $1, expected $2, got $hash"
exit 1 exit 1
@ -56,7 +56,7 @@ ln -s x $TEST_ROOT/hash-path/hello
try2 md5 "f78b733a68f5edbdf9413899339eaa4a" try2 md5 "f78b733a68f5edbdf9413899339eaa4a"
# Conversion. # Conversion.
test $($nixhash --type sha256 --to-base32 "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad") = "1b8m03r63zqhnjf7l5wnldhh7c134ap5vpj0850ymkq1iyzicy5s" test $(nix-hash --type sha256 --to-base32 "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad") = "1b8m03r63zqhnjf7l5wnldhh7c134ap5vpj0850ymkq1iyzicy5s"
test $($nixhash --type sha256 --to-base16 "1b8m03r63zqhnjf7l5wnldhh7c134ap5vpj0850ymkq1iyzicy5s") = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" test $(nix-hash --type sha256 --to-base16 "1b8m03r63zqhnjf7l5wnldhh7c134ap5vpj0850ymkq1iyzicy5s") = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
test $($nixhash --type sha1 --to-base32 "800d59cfcd3c05e900cb4e214be48f6b886a08df") = "vw46m23bizj4n8afrc0fj19wrp7mj3c0" test $(nix-hash --type sha1 --to-base32 "800d59cfcd3c05e900cb4e214be48f6b886a08df") = "vw46m23bizj4n8afrc0fj19wrp7mj3c0"
test $($nixhash --type sha1 --to-base16 "vw46m23bizj4n8afrc0fj19wrp7mj3c0") = "800d59cfcd3c05e900cb4e214be48f6b886a08df" test $(nix-hash --type sha1 --to-base16 "vw46m23bizj4n8afrc0fj19wrp7mj3c0") = "800d59cfcd3c05e900cb4e214be48f6b886a08df"

View file

@ -18,22 +18,19 @@ mkdir "$NIX_DB_DIR"
mkdir "$NIX_CONF_DIR" mkdir "$NIX_CONF_DIR"
mkdir $NIX_BIN_DIR mkdir $NIX_BIN_DIR
ln -s $nixstore $NIX_BIN_DIR/ ln -s $TOP/src/nix-store/nix-store $NIX_BIN_DIR/
ln -s $nixinstantiate $NIX_BIN_DIR/ ln -s $TOP/src/nix-instantiate/nix-instantiate $NIX_BIN_DIR/
ln -s $nixhash $NIX_BIN_DIR/ ln -s $TOP/src/nix-hash/nix-hash $NIX_BIN_DIR/
ln -s $nixenv $NIX_BIN_DIR/ ln -s $TOP/src/nix-env/nix-env $NIX_BIN_DIR/
ln -s $nixworker $NIX_BIN_DIR/ ln -s $TOP/src/nix-worker/nix-worker $NIX_BIN_DIR/
ln -s $TOP/src/bsdiff-*/bsdiff $NIX_BIN_DIR/ ln -s $TOP/src/bsdiff-*/bsdiff $NIX_BIN_DIR/
ln -s $TOP/src/bsdiff-*/bspatch $NIX_BIN_DIR/ ln -s $TOP/src/bsdiff-*/bspatch $NIX_BIN_DIR/
ln -s $TOP/scripts/nix-prefetch-url $NIX_BIN_DIR/ ln -s $TOP/scripts/nix-prefetch-url $NIX_BIN_DIR/
ln -s $TOP/scripts/nix-collect-garbage $NIX_BIN_DIR/
ln -s $TOP/scripts/nix-build $NIX_BIN_DIR/ ln -s $TOP/scripts/nix-build $NIX_BIN_DIR/
ln -s $TOP/scripts/nix-install-package $NIX_BIN_DIR/
ln -s $TOP/scripts/nix-pull $NIX_BIN_DIR/ ln -s $TOP/scripts/nix-pull $NIX_BIN_DIR/
mkdir $NIX_BIN_DIR/nix mkdir -p $NIX_BIN_DIR/nix/substituters
ln -s $NIX_BZIP2 $NIX_BIN_DIR/nix/ ln -s $NIX_BZIP2 $NIX_BIN_DIR/nix/
ln -s $TOP/scripts/copy-from-other-stores.pl $NIX_BIN_DIR/nix/ ln -s $TOP/scripts/copy-from-other-stores.pl $NIX_BIN_DIR/nix/substituters
ln -s $TOP/scripts/download-using-manifests.pl $NIX_BIN_DIR/nix/
cat > "$NIX_CONF_DIR"/nix.conf <<EOF cat > "$NIX_CONF_DIR"/nix.conf <<EOF
gc-keep-outputs = false gc-keep-outputs = false
@ -71,20 +68,15 @@ mv tmp $NIX_DATA_DIR/nix/corepkgs/nar/nar.sh
# binaries sets DYLD_LIBRARY_PATH so that Perl finds Nix's (completely # binaries sets DYLD_LIBRARY_PATH so that Perl finds Nix's (completely
# different) libutil --- so it barfs. So generate a shell wrapper # different) libutil --- so it barfs. So generate a shell wrapper
# around download-using-manifests that clears DYLD_LIBRARY_PATH. # around download-using-manifests that clears DYLD_LIBRARY_PATH.
mv $NIX_BIN_DIR/nix/download-using-manifests.pl $NIX_BIN_DIR/nix/download-using-manifests.pl.real cat > $NIX_BIN_DIR/nix/substituters/download-using-manifests.pl <<EOF
cat > $NIX_BIN_DIR/nix/download-using-manifests.pl <<EOF
#! $SHELL -e #! $SHELL -e
export DYLD_LIBRARY_PATH= export DYLD_LIBRARY_PATH=
exec $NIX_BIN_DIR/nix/download-using-manifests.pl.real "\$@" exec $TOP/scripts/download-using-manifests.pl "\$@"
EOF EOF
chmod +x $NIX_BIN_DIR/nix/download-using-manifests.pl chmod +x $NIX_BIN_DIR/nix/substituters/download-using-manifests.pl
mkdir -p $NIX_BIN_DIR/nix/substituters
mv $NIX_BIN_DIR/nix/copy-from-other-stores.pl $NIX_BIN_DIR/nix/substituters/copy-from-other-stores.pl
mv $NIX_BIN_DIR/nix/download-using-manifests.pl $NIX_BIN_DIR/nix/substituters/download-using-manifests.pl
# Initialise the database. # Initialise the database.
$nixstore --init nix-store --init
# Did anything happen? # Did anything happen?
test -e "$NIX_DB_DIR"/db.sqlite test -e "$NIX_DB_DIR"/db.sqlite

View file

@ -2,8 +2,8 @@ source common.sh
# Note: this test expects to be run *after* nix-push.sh. # Note: this test expects to be run *after* nix-push.sh.
drvPath=$($nixinstantiate ./dependencies.nix) drvPath=$(nix-instantiate ./dependencies.nix)
outPath=$($nixstore -q $drvPath) outPath=$(nix-store -q $drvPath)
clearStore clearStore
clearProfiles clearProfiles
@ -12,10 +12,10 @@ cat > $TEST_ROOT/foo.nixpkg <<EOF
NIXPKG1 file://$TEST_ROOT/manifest simple $system $drvPath $outPath NIXPKG1 file://$TEST_ROOT/manifest simple $system $drvPath $outPath
EOF EOF
$NIX_BIN_DIR/nix-install-package --non-interactive -p $profiles/test $TEST_ROOT/foo.nixpkg nix-install-package --non-interactive -p $profiles/test $TEST_ROOT/foo.nixpkg
test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 1 test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 1
clearProfiles clearProfiles
$NIX_BIN_DIR/nix-install-package --non-interactive -p $profiles/test --url file://$TEST_ROOT/foo.nixpkg nix-install-package --non-interactive -p $profiles/test --url file://$TEST_ROOT/foo.nixpkg
test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 1 test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 1

View file

@ -7,7 +7,7 @@ fail=0
for i in lang/parse-fail-*.nix; do for i in lang/parse-fail-*.nix; do
echo "parsing $i (should fail)"; echo "parsing $i (should fail)";
i=$(basename $i .nix) i=$(basename $i .nix)
if $nixinstantiate --parse-only - < lang/$i.nix; then if nix-instantiate --parse-only - < lang/$i.nix; then
echo "FAIL: $i shouldn't parse" echo "FAIL: $i shouldn't parse"
fail=1 fail=1
fi fi
@ -16,7 +16,7 @@ done
for i in lang/parse-okay-*.nix; do for i in lang/parse-okay-*.nix; do
echo "parsing $i (should succeed)"; echo "parsing $i (should succeed)";
i=$(basename $i .nix) i=$(basename $i .nix)
if ! $nixinstantiate --parse-only - < lang/$i.nix > lang/$i.out; then if ! nix-instantiate --parse-only - < lang/$i.nix > lang/$i.out; then
echo "FAIL: $i should parse" echo "FAIL: $i should parse"
fail=1 fail=1
fi fi
@ -25,7 +25,7 @@ done
for i in lang/eval-fail-*.nix; do for i in lang/eval-fail-*.nix; do
echo "evaluating $i (should fail)"; echo "evaluating $i (should fail)";
i=$(basename $i .nix) i=$(basename $i .nix)
if $nixinstantiate --eval-only lang/$i.nix; then if nix-instantiate --eval-only lang/$i.nix; then
echo "FAIL: $i shouldn't evaluate" echo "FAIL: $i shouldn't evaluate"
fail=1 fail=1
fi fi
@ -40,7 +40,7 @@ for i in lang/eval-okay-*.nix; do
if test -e lang/$i.flags; then if test -e lang/$i.flags; then
flags=$(cat lang/$i.flags) flags=$(cat lang/$i.flags)
fi fi
if ! NIX_PATH=lang/dir3:lang/dir4 $nixinstantiate $flags --eval-only --strict lang/$i.nix > lang/$i.out; then if ! NIX_PATH=lang/dir3:lang/dir4 nix-instantiate $flags --eval-only --strict lang/$i.nix > lang/$i.out; then
echo "FAIL: $i should evaluate" echo "FAIL: $i should evaluate"
fail=1 fail=1
elif ! diff lang/$i.out lang/$i.exp; then elif ! diff lang/$i.out lang/$i.exp; then
@ -50,7 +50,7 @@ for i in lang/eval-okay-*.nix; do
fi fi
if test -e lang/$i.exp.xml; then if test -e lang/$i.exp.xml; then
if ! $nixinstantiate --eval-only --xml --no-location --strict \ if ! nix-instantiate --eval-only --xml --no-location --strict \
lang/$i.nix > lang/$i.out.xml; then lang/$i.nix > lang/$i.out.xml; then
echo "FAIL: $i should evaluate" echo "FAIL: $i should evaluate"
fail=1 fail=1

View file

@ -4,7 +4,7 @@ clearStore
# Produce an escaped log file. # Produce an escaped log file.
set -x set -x
$nixbuild --log-type escapes -vv dependencies.nix 2> $TEST_ROOT/log.esc nix-build --log-type escapes -vv dependencies.nix 2> $TEST_ROOT/log.esc
# Convert it to an XML representation. # Convert it to an XML representation.
$TOP/src/nix-log2xml/nix-log2xml < $TEST_ROOT/log.esc > $TEST_ROOT/log.xml $TOP/src/nix-log2xml/nix-log2xml < $TEST_ROOT/log.esc > $TEST_ROOT/log.xml

View file

@ -3,14 +3,14 @@ source common.sh
# Tests miscellaneous commands. # Tests miscellaneous commands.
# Do all commands have help? # Do all commands have help?
$nixenv --help | grep -q install nix-env --help | grep -q install
$nixstore --help | grep -q realise nix-store --help | grep -q realise
$nixinstantiate --help | grep -q eval-only nix-instantiate --help | grep -q eval-only
$nixhash --help | grep -q base32 nix-hash --help | grep -q base32
# Can we ask for the version number? # Can we ask for the version number?
$nixenv --version | grep "$version" nix-env --version | grep "$version"
# Usage errors. # Usage errors.
$nixenv --foo 2>&1 | grep "no operation" nix-env --foo 2>&1 | grep "no operation"
$nixenv -q --foo 2>&1 | grep "unknown flag" nix-env -q --foo 2>&1 | grep "unknown flag"

View file

@ -7,16 +7,16 @@ set +e
opts="--option build-cache-failure true --print-build-trace" opts="--option build-cache-failure true --print-build-trace"
# This build should fail, and the failure should be cached. # This build should fail, and the failure should be cached.
log=$($nixbuild $opts negative-caching.nix -A fail 2>&1) && fail "should fail" log=$(nix-build $opts negative-caching.nix -A fail 2>&1) && fail "should fail"
echo "$log" | grep -q "@ build-failed" || fail "no build-failed trace" echo "$log" | grep -q "@ build-failed" || fail "no build-failed trace"
# Do it again. The build shouldn't be tried again. # Do it again. The build shouldn't be tried again.
log=$($nixbuild $opts negative-caching.nix -A fail 2>&1) && fail "should fail" log=$(nix-build $opts negative-caching.nix -A fail 2>&1) && fail "should fail"
echo "$log" | grep -q "FAIL" && fail "failed build not cached" echo "$log" | grep -q "FAIL" && fail "failed build not cached"
echo "$log" | grep -q "@ build-failed .* cached" || fail "trace doesn't say cached" echo "$log" | grep -q "@ build-failed .* cached" || fail "trace doesn't say cached"
# Check that --keep-going works properly with cached failures. # Check that --keep-going works properly with cached failures.
log=$($nixbuild $opts --keep-going negative-caching.nix -A depOnFail 2>&1) && fail "should fail" log=$(nix-build $opts --keep-going negative-caching.nix -A depOnFail 2>&1) && fail "should fail"
echo "$log" | grep -q "FAIL" && fail "failed build not cached (2)" echo "$log" | grep -q "FAIL" && fail "failed build not cached (2)"
echo "$log" | grep -q "@ build-failed .* cached" || fail "trace doesn't say cached (2)" echo "$log" | grep -q "@ build-failed .* cached" || fail "trace doesn't say cached (2)"
echo "$log" | grep -q "@ build-succeeded .*-succeed" || fail "didn't keep going" echo "$log" | grep -q "@ build-succeeded .*-succeed" || fail "didn't keep going"

View file

@ -2,7 +2,7 @@ source common.sh
clearStore clearStore
(cd $TEST_ROOT && $nixbuild ../dependencies.nix) (cd $TEST_ROOT && nix-build ../dependencies.nix)
test "$(cat $TEST_ROOT/result/foobar)" = FOOBAR test "$(cat $TEST_ROOT/result/foobar)" = FOOBAR
# The result should be retained by a GC. # The result should be retained by a GC.
@ -10,10 +10,10 @@ echo A
target=$(readLink $TEST_ROOT/result) target=$(readLink $TEST_ROOT/result)
echo B echo B
echo target is $target echo target is $target
$nixstore --gc nix-store --gc
test -e $target/foobar test -e $target/foobar
# But now it should be gone. # But now it should be gone.
rm $TEST_ROOT/result rm $TEST_ROOT/result
$nixstore --gc nix-store --gc
if test -e $target/foobar; then false; fi if test -e $target/foobar; then false; fi

View file

@ -9,11 +9,11 @@ clearStore
clearManifests clearManifests
pullCache pullCache
drvPath=$($nixinstantiate dependencies.nix) drvPath=$(nix-instantiate dependencies.nix)
outPath=$($nixstore -q $drvPath) outPath=$(nix-store -q $drvPath)
echo "building $outPath using substitutes..." echo "building $outPath using substitutes..."
$nixstore -r $outPath nix-store -r $outPath
cat $outPath/input-2/bar cat $outPath/input-2/bar
@ -22,12 +22,12 @@ clearManifests
pullCache pullCache
echo "building $drvPath using substitutes..." echo "building $drvPath using substitutes..."
$nixstore -r $drvPath nix-store -r $drvPath
cat $outPath/input-2/bar cat $outPath/input-2/bar
# Check that the derivers are set properly. # Check that the derivers are set properly.
test $($nixstore -q --deriver "$outPath") = "$drvPath" test $(nix-store -q --deriver "$outPath") = "$drvPath"
$nixstore -q --deriver $(readLink $outPath/input-2) | grep -q -- "-input-2.drv" nix-store -q --deriver $(readLink $outPath/input-2) | grep -q -- "-input-2.drv"
clearManifests clearManifests

View file

@ -1,7 +1,7 @@
source common.sh source common.sh
drvPath=$($nixinstantiate dependencies.nix) drvPath=$(nix-instantiate dependencies.nix)
outPath=$($nixstore -r $drvPath) outPath=$(nix-store -r $drvPath)
echo "pushing $drvPath" echo "pushing $drvPath"

View file

@ -8,7 +8,7 @@ clearStore
rm -f $SHARED.cur $SHARED.max rm -f $SHARED.cur $SHARED.max
outPath=$($nixbuild -j10000 parallel.nix) outPath=$(nix-build -j10000 parallel.nix)
echo "output path is $outPath" echo "output path is $outPath"
@ -27,9 +27,9 @@ clearStore
rm -f $SHARED.cur $SHARED.max rm -f $SHARED.cur $SHARED.max
drvPath=$($nixinstantiate parallel.nix --argstr sleepTime 15) drvPath=$(nix-instantiate parallel.nix --argstr sleepTime 15)
cmd="$nixstore -j1 -r $drvPath" cmd="nix-store -j1 -r $drvPath"
$cmd & $cmd &
pid1=$! pid1=$!

View file

@ -6,7 +6,7 @@ max=500
reference=$NIX_STORE_DIR/abcdef reference=$NIX_STORE_DIR/abcdef
touch $reference touch $reference
(echo $reference && echo && echo 0) | $nixstore --register-validity (echo $reference && echo && echo 0) | nix-store --register-validity
echo "making registration..." echo "making registration..."
@ -22,11 +22,11 @@ done > $TEST_ROOT/reg_info
echo "registering..." echo "registering..."
$nixstore --register-validity < $TEST_ROOT/reg_info nix-store --register-validity < $TEST_ROOT/reg_info
echo "collecting garbage..." echo "collecting garbage..."
ln -sfn $reference "$NIX_STATE_DIR"/gcroots/ref ln -sfn $reference "$NIX_STATE_DIR"/gcroots/ref
$nixstore --gc nix-store --gc
if test "$(sqlite3 ./test-tmp/db/db.sqlite 'select count(*) from Refs')" -ne 0; then if test "$(sqlite3 ./test-tmp/db/db.sqlite 'select count(*) from Refs')" -ne 0; then
echo "referrers not cleaned up" echo "referrers not cleaned up"

View file

@ -10,11 +10,11 @@ clearManifests
startDaemon startDaemon
# Determine the output path of the "good" derivation. # Determine the output path of the "good" derivation.
goodOut=$($nixstore -q $($nixinstantiate ./secure-drv-outputs.nix -A good)) goodOut=$(nix-store -q $(nix-instantiate ./secure-drv-outputs.nix -A good))
# Instantiate the "bad" derivation. # Instantiate the "bad" derivation.
badDrv=$($nixinstantiate ./secure-drv-outputs.nix -A bad) badDrv=$(nix-instantiate ./secure-drv-outputs.nix -A bad)
badOut=$($nixstore -q $badDrv) badOut=$(nix-store -q $badDrv)
# Rewrite the bad derivation to produce the output path of the good # Rewrite the bad derivation to produce the output path of the good
# derivation. # derivation.
@ -23,12 +23,12 @@ sed -e "s|$badOut|$goodOut|g" < $badDrv > $TEST_ROOT/bad.drv
# Add the manipulated derivation to the store and build it. This # Add the manipulated derivation to the store and build it. This
# should fail. # should fail.
if badDrv2=$($nixstore --add $TEST_ROOT/bad.drv); then if badDrv2=$(nix-store --add $TEST_ROOT/bad.drv); then
$nixstore -r "$badDrv2" nix-store -r "$badDrv2"
fi fi
# Now build the good derivation. # Now build the good derivation.
goodOut2=$($nixbuild ./secure-drv-outputs.nix -A good) goodOut2=$(nix-build ./secure-drv-outputs.nix -A good)
test "$goodOut" = "$goodOut2" test "$goodOut" = "$goodOut2"
if ! test -e "$goodOut"/good; then if ! test -e "$goodOut"/good; then

View file

@ -1,12 +1,12 @@
source common.sh source common.sh
drvPath=$($nixinstantiate simple.nix) drvPath=$(nix-instantiate simple.nix)
test "$($nixstore -q --binding system "$drvPath")" = "$system" test "$(nix-store -q --binding system "$drvPath")" = "$system"
echo "derivation is $drvPath" echo "derivation is $drvPath"
outPath=$($nixstore -rvv "$drvPath") outPath=$(nix-store -rvv "$drvPath")
echo "output path is $outPath" echo "output path is $outPath"
@ -15,10 +15,10 @@ if test "$text" != "Hello World!"; then exit 1; fi
# Directed delete: $outPath is not reachable from a root, so it should # Directed delete: $outPath is not reachable from a root, so it should
# be deleteable. # be deleteable.
$nixstore --delete $outPath nix-store --delete $outPath
if test -e $outPath/hello; then false; fi if test -e $outPath/hello; then false; fi
outPath="$(NIX_STORE_DIR=/foo $nixinstantiate --readonly-mode hash-check.nix)" outPath="$(NIX_STORE_DIR=/foo nix-instantiate --readonly-mode hash-check.nix)"
if test "$outPath" != "/foo/lfy1s6ca46rm5r6w4gg9hc0axiakjcnm-dependencies.drv"; then if test "$outPath" != "/foo/lfy1s6ca46rm5r6w4gg9hc0axiakjcnm-dependencies.drv"; then
echo "hashDerivationModulo appears broken, got $outPath" echo "hashDerivationModulo appears broken, got $outPath"
exit 1 exit 1

View file

@ -3,20 +3,20 @@ source common.sh
clearStore clearStore
# Instantiate. # Instantiate.
drvPath=$($nixinstantiate simple.nix) drvPath=$(nix-instantiate simple.nix)
echo "derivation is $drvPath" echo "derivation is $drvPath"
# Find the output path. # Find the output path.
outPath=$($nixstore -qvv "$drvPath") outPath=$(nix-store -qvv "$drvPath")
echo "output path is $outPath" echo "output path is $outPath"
echo $outPath > $TEST_ROOT/sub-paths echo $outPath > $TEST_ROOT/sub-paths
export NIX_SUBSTITUTERS=$(pwd)/substituter.sh export NIX_SUBSTITUTERS=$(pwd)/substituter.sh
$nixstore -r "$drvPath" --dry-run 2>&1 | grep -q "1.00 MiB.*2.00 MiB" nix-store -r "$drvPath" --dry-run 2>&1 | grep -q "1.00 MiB.*2.00 MiB"
$nixstore -rvv "$drvPath" nix-store -rvv "$drvPath"
text=$(cat "$outPath"/hello) text=$(cat "$outPath"/hello)
if test "$text" != "Hallo Wereld"; then echo "wrong substitute output: $text"; exit 1; fi if test "$text" != "Hallo Wereld"; then echo "wrong substitute output: $text"; exit 1; fi

View file

@ -3,11 +3,11 @@ source common.sh
clearStore clearStore
# Instantiate. # Instantiate.
drvPath=$($nixinstantiate simple.nix) drvPath=$(nix-instantiate simple.nix)
echo "derivation is $drvPath" echo "derivation is $drvPath"
# Find the output path. # Find the output path.
outPath=$($nixstore -qvvvvv "$drvPath") outPath=$(nix-store -qvvvvv "$drvPath")
echo "output path is $outPath" echo "output path is $outPath"
echo $outPath > $TEST_ROOT/sub-paths echo $outPath > $TEST_ROOT/sub-paths
@ -15,7 +15,7 @@ echo $outPath > $TEST_ROOT/sub-paths
# First try a substituter that fails, then one that succeeds # First try a substituter that fails, then one that succeeds
export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh:$(pwd)/substituter.sh export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh:$(pwd)/substituter.sh
$nixstore -j0 -rvv "$drvPath" nix-store -j0 -rvv "$drvPath"
text=$(cat "$outPath"/hello) text=$(cat "$outPath"/hello)
if test "$text" != "Hallo Wereld"; then echo "wrong substitute output: $text"; exit 1; fi if test "$text" != "Hallo Wereld"; then echo "wrong substitute output: $text"; exit 1; fi

View file

@ -2,14 +2,14 @@
source common.sh source common.sh
drvPath=$($nixinstantiate timeout.nix) drvPath=$(nix-instantiate timeout.nix)
test "$($nixstore -q --binding system "$drvPath")" = "$system" test "$(nix-store -q --binding system "$drvPath")" = "$system"
echo "derivation is $drvPath" echo "derivation is $drvPath"
failed=0 failed=0
messages="`$nixstore -r --timeout 2 $drvPath 2>&1 || failed=1`" messages="`nix-store -r --timeout 2 $drvPath 2>&1 || failed=1`"
if test $failed -ne 0; then if test $failed -ne 0; then
echo "error: \`nix-store' succeeded; should have timed out" >&2 echo "error: \`nix-store' succeeded; should have timed out" >&2
exit 1 exit 1

View file

@ -5,110 +5,110 @@ clearProfiles
set -x set -x
# Query installed: should be empty. # Query installed: should be empty.
test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 0 test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 0
# Query available: should contain several. # Query available: should contain several.
test "$($nixenv -p $profiles/test -f ./user-envs.nix -qa '*' | wc -l)" -eq 5 test "$(nix-env -p $profiles/test -f ./user-envs.nix -qa '*' | wc -l)" -eq 5
# Query descriptions. # Query descriptions.
$nixenv -p $profiles/test -f ./user-envs.nix -qa '*' --description | grep silly nix-env -p $profiles/test -f ./user-envs.nix -qa '*' --description | grep silly
# Install "foo-1.0". # Install "foo-1.0".
$nixenv -p $profiles/test -f ./user-envs.nix -i foo-1.0 nix-env -p $profiles/test -f ./user-envs.nix -i foo-1.0
# Query installed: should contain foo-1.0 now (which should be # Query installed: should contain foo-1.0 now (which should be
# executable). # executable).
test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 1 test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 1
$nixenv -p $profiles/test -q '*' | grep -q foo-1.0 nix-env -p $profiles/test -q '*' | grep -q foo-1.0
test "$($profiles/test/bin/foo)" = "foo-1.0" test "$($profiles/test/bin/foo)" = "foo-1.0"
# Store the path of foo-1.0. # Store the path of foo-1.0.
outPath10=$($nixenv -p $profiles/test -q --out-path --no-name '*' | grep foo-1.0) outPath10=$(nix-env -p $profiles/test -q --out-path --no-name '*' | grep foo-1.0)
echo "foo-1.0 = $outPath10" echo "foo-1.0 = $outPath10"
test -n "$outPath10" test -n "$outPath10"
# Install "foo-2.0pre1": should remove foo-1.0. # Install "foo-2.0pre1": should remove foo-1.0.
$nixenv -p $profiles/test -f ./user-envs.nix -i foo-2.0pre1 nix-env -p $profiles/test -f ./user-envs.nix -i foo-2.0pre1
# Query installed: should contain foo-2.0pre1 now. # Query installed: should contain foo-2.0pre1 now.
test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 1 test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 1
$nixenv -p $profiles/test -q '*' | grep -q foo-2.0pre1 nix-env -p $profiles/test -q '*' | grep -q foo-2.0pre1
test "$($profiles/test/bin/foo)" = "foo-2.0pre1" test "$($profiles/test/bin/foo)" = "foo-2.0pre1"
# Upgrade "foo": should install foo-2.0. # Upgrade "foo": should install foo-2.0.
$nixenv -p $profiles/test -f ./user-envs.nix -u foo nix-env -p $profiles/test -f ./user-envs.nix -u foo
# Query installed: should contain foo-2.0 now. # Query installed: should contain foo-2.0 now.
test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 1 test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 1
$nixenv -p $profiles/test -q '*' | grep -q foo-2.0 nix-env -p $profiles/test -q '*' | grep -q foo-2.0
test "$($profiles/test/bin/foo)" = "foo-2.0" test "$($profiles/test/bin/foo)" = "foo-2.0"
# Store the path of foo-2.0. # Store the path of foo-2.0.
outPath20=$($nixenv -p $profiles/test -q --out-path --no-name '*' | grep foo-2.0) outPath20=$(nix-env -p $profiles/test -q --out-path --no-name '*' | grep foo-2.0)
test -n "$outPath20" test -n "$outPath20"
# Install bar-0.1, uninstall foo. # Install bar-0.1, uninstall foo.
$nixenv -p $profiles/test -f ./user-envs.nix -i bar-0.1 nix-env -p $profiles/test -f ./user-envs.nix -i bar-0.1
$nixenv -p $profiles/test -f ./user-envs.nix -e foo nix-env -p $profiles/test -f ./user-envs.nix -e foo
# Query installed: should only contain bar-0.1 now. # Query installed: should only contain bar-0.1 now.
if $nixenv -p $profiles/test -q '*' | grep -q foo; then false; fi if nix-env -p $profiles/test -q '*' | grep -q foo; then false; fi
$nixenv -p $profiles/test -q '*' | grep -q bar nix-env -p $profiles/test -q '*' | grep -q bar
# Rollback: should bring "foo" back. # Rollback: should bring "foo" back.
$nixenv -p $profiles/test --rollback nix-env -p $profiles/test --rollback
$nixenv -p $profiles/test -q '*' | grep -q foo-2.0 nix-env -p $profiles/test -q '*' | grep -q foo-2.0
$nixenv -p $profiles/test -q '*' | grep -q bar nix-env -p $profiles/test -q '*' | grep -q bar
# Rollback again: should remove "bar". # Rollback again: should remove "bar".
$nixenv -p $profiles/test --rollback nix-env -p $profiles/test --rollback
$nixenv -p $profiles/test -q '*' | grep -q foo-2.0 nix-env -p $profiles/test -q '*' | grep -q foo-2.0
if $nixenv -p $profiles/test -q '*' | grep -q bar; then false; fi if nix-env -p $profiles/test -q '*' | grep -q bar; then false; fi
# Count generations. # Count generations.
$nixenv -p $profiles/test --list-generations nix-env -p $profiles/test --list-generations
test "$($nixenv -p $profiles/test --list-generations | wc -l)" -eq 5 test "$(nix-env -p $profiles/test --list-generations | wc -l)" -eq 5
# Install foo-1.0, now using its store path. # Install foo-1.0, now using its store path.
echo $outPath10 echo $outPath10
$nixenv -p $profiles/test -i "$outPath10" nix-env -p $profiles/test -i "$outPath10"
$nixenv -p $profiles/test -q '*' | grep -q foo-1.0 nix-env -p $profiles/test -q '*' | grep -q foo-1.0
# Uninstall foo-1.0, using a symlink to its store path. # Uninstall foo-1.0, using a symlink to its store path.
ln -sfn $outPath10/bin/foo $TEST_ROOT/symlink ln -sfn $outPath10/bin/foo $TEST_ROOT/symlink
$nixenv -p $profiles/test -e $TEST_ROOT/symlink nix-env -p $profiles/test -e $TEST_ROOT/symlink
if $nixenv -p $profiles/test -q '*' | grep -q foo; then false; fi if nix-env -p $profiles/test -q '*' | grep -q foo; then false; fi
# Install foo-1.0, now using a symlink to its store path. # Install foo-1.0, now using a symlink to its store path.
$nixenv -p $profiles/test -i $TEST_ROOT/symlink nix-env -p $profiles/test -i $TEST_ROOT/symlink
$nixenv -p $profiles/test -q '*' | grep -q foo nix-env -p $profiles/test -q '*' | grep -q foo
# Delete all old generations. # Delete all old generations.
$nixenv -p $profiles/test --delete-generations old nix-env -p $profiles/test --delete-generations old
# Run the garbage collector. This should get rid of foo-2.0 but not # Run the garbage collector. This should get rid of foo-2.0 but not
# foo-1.0. # foo-1.0.
$NIX_BIN_DIR/nix-collect-garbage nix-collect-garbage
test -e "$outPath10" test -e "$outPath10"
if test -e "$outPath20"; then false; fi if test -e "$outPath20"; then false; fi
# Uninstall everything # Uninstall everything
$nixenv -p $profiles/test -f ./user-envs.nix -e '*' nix-env -p $profiles/test -f ./user-envs.nix -e '*'
test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 0 test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 0
# Installing "foo" should only install the newest foo. # Installing "foo" should only install the newest foo.
$nixenv -p $profiles/test -f ./user-envs.nix -i foo nix-env -p $profiles/test -f ./user-envs.nix -i foo
test "$($nixenv -p $profiles/test -q '*' | grep foo- | wc -l)" -eq 1 test "$(nix-env -p $profiles/test -q '*' | grep foo- | wc -l)" -eq 1
$nixenv -p $profiles/test -q '*' | grep -q foo-2.0 nix-env -p $profiles/test -q '*' | grep -q foo-2.0
# On the other hand, this should install both (and should fail due to # On the other hand, this should install both (and should fail due to
# a collision). # a collision).
$nixenv -p $profiles/test -f ./user-envs.nix -e '*' nix-env -p $profiles/test -f ./user-envs.nix -e '*'
if $nixenv -p $profiles/test -f ./user-envs.nix -i foo-1.0 foo-2.0; then false; fi if nix-env -p $profiles/test -f ./user-envs.nix -i foo-1.0 foo-2.0; then false; fi
# Installing "*" should install one foo and one bar. # Installing "*" should install one foo and one bar.
$nixenv -p $profiles/test -f ./user-envs.nix -e '*' nix-env -p $profiles/test -f ./user-envs.nix -e '*'
$nixenv -p $profiles/test -f ./user-envs.nix -i '*' nix-env -p $profiles/test -f ./user-envs.nix -i '*'
test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 2 test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 2
$nixenv -p $profiles/test -q '*' | grep -q foo-2.0 nix-env -p $profiles/test -q '*' | grep -q foo-2.0
$nixenv -p $profiles/test -q '*' | grep -q bar-0.1.1 nix-env -p $profiles/test -q '*' | grep -q bar-0.1.1

View file

@ -1,3 +1,3 @@
source common.sh source common.sh
$nixstore --verify nix-store --verify