mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-21 21:46:15 +02:00
Fix tests
So all these years I was totally deluded about the meaning of "set -e". You might think that it causes statements like "false && true" or "! true" to fail, but it doesn't...
This commit is contained in:
parent
809ca33806
commit
3f80060500
9 changed files with 20 additions and 26 deletions
|
@ -20,4 +20,4 @@ while read x y drv rest; do
|
|||
echo "# decline" >&2
|
||||
fi
|
||||
|
||||
done
|
||||
done
|
||||
|
|
|
@ -16,4 +16,4 @@ cmp case.nar $TEST_ROOT/case.nar
|
|||
# Check whether we detect true collisions (e.g. those remaining after
|
||||
# removal of the suffix).
|
||||
touch "$TEST_ROOT/case/xt_CONNMARK.h~nix~case~hack~3"
|
||||
! nix-store $opts --dump $TEST_ROOT/case > /dev/null
|
||||
(! nix-store $opts --dump $TEST_ROOT/case > /dev/null)
|
||||
|
|
|
@ -1,24 +1,22 @@
|
|||
source common.sh
|
||||
|
||||
set -x
|
||||
|
||||
RESULT=$TEST_ROOT/result
|
||||
|
||||
dep=$(nix-build -o $RESULT check-refs.nix -A dep)
|
||||
|
||||
# test1 references dep, not itself.
|
||||
test1=$(nix-build -o $RESULT check-refs.nix -A test1)
|
||||
! nix-store -q --references $test1 | grep -q $test1
|
||||
(! nix-store -q --references $test1 | grep -q $test1)
|
||||
nix-store -q --references $test1 | grep -q $dep
|
||||
|
||||
# test2 references src, not itself nor dep.
|
||||
test2=$(nix-build -o $RESULT check-refs.nix -A test2)
|
||||
! nix-store -q --references $test2 | grep -q $test2
|
||||
! nix-store -q --references $test2 | grep -q $dep
|
||||
(! nix-store -q --references $test2 | grep -q $test2)
|
||||
(! nix-store -q --references $test2 | grep -q $dep)
|
||||
nix-store -q --references $test2 | grep -q aux-ref
|
||||
|
||||
# test3 should fail (unallowed ref).
|
||||
! nix-build -o $RESULT check-refs.nix -A test3
|
||||
(! nix-build -o $RESULT check-refs.nix -A test3)
|
||||
|
||||
# test4 should succeed.
|
||||
nix-build -o $RESULT check-refs.nix -A test4
|
||||
|
@ -27,10 +25,10 @@ nix-build -o $RESULT check-refs.nix -A test4
|
|||
nix-build -o $RESULT check-refs.nix -A test5
|
||||
|
||||
# test6 should fail (unallowed self-ref).
|
||||
! nix-build -o $RESULT check-refs.nix -A test6
|
||||
(! nix-build -o $RESULT check-refs.nix -A test6)
|
||||
|
||||
# test7 should succeed (allowed self-ref).
|
||||
nix-build -o $RESULT check-refs.nix -A test7
|
||||
|
||||
# test8 should fail (toFile depending on derivation output).
|
||||
! nix-build -o $RESULT check-refs.nix -A test8
|
||||
(! nix-build -o $RESULT check-refs.nix -A test8)
|
||||
|
|
|
@ -12,7 +12,6 @@ ln -s xyzzy $TEST_ROOT/filterin/link
|
|||
|
||||
nix-build ./filter-source.nix -o $TEST_ROOT/filterout
|
||||
|
||||
set -x
|
||||
test ! -e $TEST_ROOT/filterout/foo/bar
|
||||
test -e $TEST_ROOT/filterout/xyzzy
|
||||
test -e $TEST_ROOT/filterout/bak
|
||||
|
|
|
@ -11,7 +11,7 @@ outPath2=$(nix-store -q $drvPath2)
|
|||
drvPath3=$(nix-instantiate simple.nix)
|
||||
outPath3=$(nix-store -r $drvPath3)
|
||||
|
||||
! test -e $outPath3.lock
|
||||
(! test -e $outPath3.lock)
|
||||
touch $outPath3.lock
|
||||
|
||||
rm -f "$NIX_STATE_DIR"/gcroots/foo*
|
||||
|
@ -50,9 +50,9 @@ rm -f "$NIX_STATE_DIR"/gcroots/foo*
|
|||
|
||||
# The collector should have deleted lock files for paths that have
|
||||
# been built previously.
|
||||
! test -e $outPath3.lock
|
||||
(! test -e $outPath3.lock)
|
||||
|
||||
# If we run the collector now, it should delete outPath1/2.
|
||||
nix-collect-garbage
|
||||
! test -e $outPath1
|
||||
! test -e $outPath2
|
||||
(! test -e $outPath1)
|
||||
(! test -e $outPath2)
|
||||
|
|
|
@ -3,7 +3,7 @@ source common.sh
|
|||
export TEST_VAR=foo # for eval-okay-getenv.nix
|
||||
|
||||
nix-instantiate --eval -E 'builtins.trace "Hello" 123' 2>&1 | grep -q Hello
|
||||
! nix-instantiate --show-trace --eval -E 'builtins.addErrorContext "Hello" 123' 2>&1 | grep -q Hello
|
||||
(! nix-instantiate --show-trace --eval -E 'builtins.addErrorContext "Hello" 123' 2>&1 | grep -q Hello)
|
||||
nix-instantiate --show-trace --eval -E 'builtins.addErrorContext "Hello" (throw "Foo")' 2>&1 | grep -q Hello
|
||||
|
||||
set +x
|
||||
|
|
|
@ -3,7 +3,6 @@ source common.sh
|
|||
clearStore
|
||||
|
||||
# Produce an escaped log file.
|
||||
set -x
|
||||
path=$(nix-build --log-type escapes -vv dependencies.nix --no-out-link 2> $TEST_ROOT/log.esc)
|
||||
|
||||
# Convert it to an XML representation.
|
||||
|
@ -20,6 +19,6 @@ fi
|
|||
# Test compressed logs.
|
||||
clearStore
|
||||
rm -rf $NIX_LOG_DIR
|
||||
! nix-store -l $path
|
||||
(! nix-store -l $path)
|
||||
nix-build dependencies.nix --no-out-link --option build-compress-log true
|
||||
[ "$(nix-store -l $path)" = FOO ]
|
||||
|
|
|
@ -18,7 +18,7 @@ grep -q 'multiple-outputs-b.drv",\["out"\]' $drvPath
|
|||
outPath=$(nix-build multiple-outputs.nix -A d --no-out-link)
|
||||
drvPath=$(cat $outPath/drv)
|
||||
outPath=$(nix-store -q $drvPath)
|
||||
! [ -e "$outPath" ]
|
||||
(! [ -e "$outPath" ])
|
||||
|
||||
# Do a build of something that depends on a derivation with multiple
|
||||
# outputs.
|
||||
|
@ -30,7 +30,7 @@ echo "output path is $outPath"
|
|||
# Test nix-build on a derivation with multiple outputs.
|
||||
nix-build multiple-outputs.nix -A a -o $TEST_ROOT/result
|
||||
[ -e $TEST_ROOT/result-first ]
|
||||
! [ -e $TEST_ROOT/result-second ]
|
||||
(! [ -e $TEST_ROOT/result-second ])
|
||||
nix-build multiple-outputs.nix -A a.all -o $TEST_ROOT/result
|
||||
[ "$(cat $TEST_ROOT/result-first/file)" = "first" ]
|
||||
[ "$(cat $TEST_ROOT/result-second/file)" = "second" ]
|
||||
|
|
|
@ -3,8 +3,6 @@ source common.sh
|
|||
clearStore
|
||||
clearProfiles
|
||||
|
||||
set -x
|
||||
|
||||
# Query installed: should be empty.
|
||||
test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 0
|
||||
|
||||
|
@ -46,7 +44,7 @@ nix-env -qas | grep -q -- '--- bar-0.1'
|
|||
|
||||
# Disable foo.
|
||||
nix-env --set-flag active false foo
|
||||
! [ -e "$profiles/test/bin/foo" ]
|
||||
(! [ -e "$profiles/test/bin/foo" ])
|
||||
|
||||
# Enable foo.
|
||||
nix-env --set-flag active true foo
|
||||
|
@ -116,7 +114,7 @@ nix-store -q --referrers-closure $profiles/test | grep "$(nix-store -q --resolve
|
|||
ln -sfn $outPath10/bin/foo $TEST_ROOT/symlink
|
||||
nix-env -e $TEST_ROOT/symlink
|
||||
if nix-env -q '*' | grep -q foo; then false; fi
|
||||
! nix-store -qR $profiles/test | grep "$outPath10"
|
||||
(! nix-store -qR $profiles/test | grep "$outPath10")
|
||||
|
||||
# Install foo-1.0, now using a symlink to its store path.
|
||||
nix-env -i $TEST_ROOT/symlink
|
||||
|
@ -129,7 +127,7 @@ nix-env --delete-generations old
|
|||
# foo-1.0.
|
||||
nix-collect-garbage
|
||||
test -e "$outPath10"
|
||||
! [ -e "$outPath20" ]
|
||||
(! [ -e "$outPath20" ])
|
||||
|
||||
# Uninstall everything
|
||||
nix-env -e '*'
|
||||
|
@ -143,7 +141,7 @@ nix-env -q '*' | grep -q foo-2.0
|
|||
# On the other hand, this should install both (and should fail due to
|
||||
# a collision).
|
||||
nix-env -e '*'
|
||||
! nix-env -i foo-1.0 foo-2.0
|
||||
(! nix-env -i foo-1.0 foo-2.0)
|
||||
|
||||
# Installing "*" should install one foo and one bar.
|
||||
nix-env -e '*'
|
||||
|
|
Loading…
Reference in a new issue