guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

157/376: Fix tests


From: Ludovic Courtès
Subject: 157/376: Fix tests
Date: Wed, 28 Jan 2015 22:04:43 +0000

civodul pushed a commit to tag 1.8
in repository guix.

commit 3f80060500bb3a9dff192c11af63da7364673ab0
Author: Eelco Dolstra <address@hidden>
Date:   Thu Aug 21 21:50:19 2014 +0200

    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...
---
 tests/build-hook.hook.sh  |    2 +-
 tests/case-hack.sh        |    2 +-
 tests/check-refs.sh       |   14 ++++++--------
 tests/filter-source.sh    |    1 -
 tests/gc-concurrent.sh    |    8 ++++----
 tests/lang.sh             |    2 +-
 tests/logging.sh          |    3 +--
 tests/multiple-outputs.sh |    4 ++--
 tests/user-envs.sh        |   10 ++++------
 9 files changed, 20 insertions(+), 26 deletions(-)

diff --git a/tests/build-hook.hook.sh b/tests/build-hook.hook.sh
index ff70998..c7472ea 100755
--- a/tests/build-hook.hook.sh
+++ b/tests/build-hook.hook.sh
@@ -20,4 +20,4 @@ while read x y drv rest; do
         echo "# decline" >&2
     fi
 
-done
\ No newline at end of file
+done
diff --git a/tests/case-hack.sh b/tests/case-hack.sh
index ebc7cb1..61bf9b9 100644
--- a/tests/case-hack.sh
+++ b/tests/case-hack.sh
@@ -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)
diff --git a/tests/check-refs.sh b/tests/check-refs.sh
index 08fe01e..9e10366 100644
--- a/tests/check-refs.sh
+++ b/tests/check-refs.sh
@@ -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)
diff --git a/tests/filter-source.sh b/tests/filter-source.sh
index f7a096e..1f8dcee 100644
--- a/tests/filter-source.sh
+++ b/tests/filter-source.sh
@@ -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
diff --git a/tests/gc-concurrent.sh b/tests/gc-concurrent.sh
index 0bc5a12..d395930 100644
--- a/tests/gc-concurrent.sh
+++ b/tests/gc-concurrent.sh
@@ -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)
diff --git a/tests/lang.sh b/tests/lang.sh
index 7157a68..c797a2a 100644
--- a/tests/lang.sh
+++ b/tests/lang.sh
@@ -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
diff --git a/tests/logging.sh b/tests/logging.sh
index 0113ed1..77b2337 100644
--- a/tests/logging.sh
+++ b/tests/logging.sh
@@ -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 ]
diff --git a/tests/multiple-outputs.sh b/tests/multiple-outputs.sh
index ac622a7..7ac7790 100644
--- a/tests/multiple-outputs.sh
+++ b/tests/multiple-outputs.sh
@@ -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" ]
diff --git a/tests/user-envs.sh b/tests/user-envs.sh
index 0d997ac..c9eed5a 100644
--- a/tests/user-envs.sh
+++ b/tests/user-envs.sh
@@ -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 '*'



reply via email to

[Prev in Thread] Current Thread [Next in Thread]