about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2007-08-13T13·15+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2007-08-13T13·15+0000
commit550ba9ebb4b1b2415c9930879cfa6937f7fa916a (patch)
tree3c15b0a01c59be162a17bb003d09fbd80ba01aa1
parent3757ee589f46a401fdacaa2126e6bf4902eee23d (diff)
* Fix the tests.
-rw-r--r--tests/Makefile.am9
-rw-r--r--tests/common.sh.in4
-rw-r--r--tests/fallback.nix.in7
-rw-r--r--tests/fallback.sh12
-rw-r--r--tests/nix-pull.sh4
-rw-r--r--tests/simple.builder.sh2
-rwxr-xr-xtests/substituter.sh27
-rwxr-xr-xtests/substituter2.sh21
-rw-r--r--tests/substitutes.nix.in6
-rw-r--r--tests/substitutes.sh14
-rw-r--r--tests/substitutes2.nix.in6
-rw-r--r--tests/substitutes2.sh18
12 files changed, 67 insertions, 63 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bfb8508a02b5..31ad159b06b2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,14 +2,11 @@ TESTS_ENVIRONMENT = $(SHELL) -e
 
 extra1 = $(shell pwd)/test-tmp/shared
 
-simple.sh: simple.nix
+simple.sh substitutes.sh substitutes2.sh fallback.sh: simple.nix
 dependencies.sh gc.sh nix-push.sh nix-pull.in logging.sh nix-build.sh install-package.sh check-refs.sh: dependencies.nix
 locking.sh: locking.nix
 parallel.sh: parallel.nix
 build-hook.sh: build-hook.nix
-substitutes.sh: substitutes.nix
-substitutes2.sh: substitutes2.nix
-fallback.sh: fallback.nix
 gc-concurrent.sh: gc-concurrent.nix gc-concurrent2.nix
 user-envs.sh: user-envs.nix
 fixed.sh: fixed.nix
@@ -36,11 +33,9 @@ EXTRA_DIST = $(TESTS) \
   locking.nix.in locking.builder.sh \
   parallel.nix.in parallel.builder.sh \
   build-hook.nix.in build-hook.hook.sh \
-  substitutes.nix.in substituter.sh \
-  substitutes2.nix.in substituter2.sh \
+  substituter.sh substituter2.sh \
   gc-concurrent.nix.in gc-concurrent.builder.sh \
   gc-concurrent2.nix.in gc-concurrent2.builder.sh \
-  fallback.nix.in \
   user-envs.nix.in user-envs.builder.sh \
   fixed.nix.in fixed.builder1.sh fixed.builder2.sh \
   gc-runtime.nix.in \
diff --git a/tests/common.sh.in b/tests/common.sh.in
index 32759bab01d2..1b8bb3e7df42 100644
--- a/tests/common.sh.in
+++ b/tests/common.sh.in
@@ -65,3 +65,7 @@ clearProfiles() {
     profiles="$NIX_STATE_DIR"/profiles
     rm -f $profiles/*
 }
+
+clearManifests() {
+    rm -f $NIX_STATE_DIR/manifests/*
+}
diff --git a/tests/fallback.nix.in b/tests/fallback.nix.in
deleted file mode 100644
index e47b59823bd0..000000000000
--- a/tests/fallback.nix.in
+++ /dev/null
@@ -1,7 +0,0 @@
-derivation {
-  name = "fall-back";
-  system = "@system@";
-  builder = "@shell@";
-  args = ["-e" "-x" ./simple.builder.sh];
-  goodPath = "@testPath@";
-}
diff --git a/tests/fallback.sh b/tests/fallback.sh
index 482e4ce5b72c..24889a452881 100644
--- a/tests/fallback.sh
+++ b/tests/fallback.sh
@@ -1,15 +1,19 @@
 source common.sh
 
-drvPath=$($nixinstantiate fallback.nix)
+clearStore
+
+drvPath=$($nixinstantiate simple.nix)
 echo "derivation is $drvPath"
 
 outPath=$($nixstore -q --fallback "$drvPath")
 echo "output path is $outPath"
 
-# Register a non-existant substitute
-(echo $outPath && echo "" && echo $TOP/no-such-program && echo 0 && echo 0) | $nixstore --register-substitutes
+# Build with a substitute that fails.  This should fail.
+export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh
+if $nixstore -r "$drvPath"; then echo unexpected fallback; exit 1; fi
 
-# Build the derivation
+# Build with a substitute that fails.  This should fall back to a source build.
+export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh
 $nixstore -r --fallback "$drvPath"
 
 text=$(cat "$outPath"/hello)
diff --git a/tests/nix-pull.sh b/tests/nix-pull.sh
index a847510cebfe..5ef3e55cae51 100644
--- a/tests/nix-pull.sh
+++ b/tests/nix-pull.sh
@@ -6,6 +6,7 @@ pullCache () {
 }
 
 clearStore
+clearManifests
 pullCache
 
 drvPath=$($nixinstantiate dependencies.nix)
@@ -17,6 +18,7 @@ $nixstore -r $outPath
 cat $outPath/input-2/bar
 
 clearStore
+clearManifests
 pullCache
 
 echo "building $drvPath using substitutes..."
@@ -28,4 +30,4 @@ cat $outPath/input-2/bar
 test $($nixstore -q --deriver "$outPath") = "$drvPath"
 $nixstore -q --deriver $(readLink $outPath/input-2) | grep -q -- "-input-2.drv" 
 
-$nixstore --clear-substitutes
+clearManifests
diff --git a/tests/simple.builder.sh b/tests/simple.builder.sh
index 536faec14915..569e8ca88c1e 100644
--- a/tests/simple.builder.sh
+++ b/tests/simple.builder.sh
@@ -1,7 +1,7 @@
 echo "PATH=$PATH"
 
 # Verify that the PATH is empty.
-if mkdir foo; then exit 1; fi
+if mkdir foo 2> /dev/null; then exit 1; fi
 
 # Set a PATH (!!! impure).
 export PATH=$goodPath
diff --git a/tests/substituter.sh b/tests/substituter.sh
index 005e97605c91..96fb95b91f6b 100755
--- a/tests/substituter.sh
+++ b/tests/substituter.sh
@@ -1,10 +1,19 @@
-#! /bin/sh -ex
-echo $*
-
-case $* in
-    *)
-        mkdir $1
-        echo $3 $4 > $1/hello
-        ;;
-esac        
+#! /bin/sh -e
+echo substituter args: $* >&2
 
+if test $1 = "--query-paths"; then
+    cat $TEST_ROOT/sub-paths
+elif test $1 = "--query-info"; then
+    shift
+    for i in in $@; do
+        echo $i
+        echo "" # deriver
+        echo 0 # nr of refs
+    done
+elif test $1 = "--substitute"; then
+    mkdir $2
+    echo "Hallo Wereld" > $2/hello
+else
+    echo "unknown substituter operation"
+    exit 1
+fi
diff --git a/tests/substituter2.sh b/tests/substituter2.sh
index c4e1bfec7b39..1bcf65a54d0e 100755
--- a/tests/substituter2.sh
+++ b/tests/substituter2.sh
@@ -1,3 +1,18 @@
-#! /bin/sh -ex
-echo $*
-exit 1
+#! /bin/sh -e
+echo substituter2 args: $* >&2
+
+if test $1 = "--query-paths"; then
+    cat $TEST_ROOT/sub-paths
+elif test $1 = "--query-info"; then
+    shift
+    for i in in $@; do
+        echo $i
+        echo "" # deriver
+        echo 0 # nr of refs
+    done
+elif test $1 = "--substitute"; then
+    exit 1
+else
+    echo "unknown substituter operation"
+    exit 1
+fi
diff --git a/tests/substitutes.nix.in b/tests/substitutes.nix.in
deleted file mode 100644
index e3473621608d..000000000000
--- a/tests/substitutes.nix.in
+++ /dev/null
@@ -1,6 +0,0 @@
-derivation {
-  name = "substitutes";
-  system = "@system@";
-  builder = "@shell@";
-  args = ["-e" "-x" ./simple.builder.sh];
-}
\ No newline at end of file
diff --git a/tests/substitutes.sh b/tests/substitutes.sh
index c44f012f5924..042827314bd9 100644
--- a/tests/substitutes.sh
+++ b/tests/substitutes.sh
@@ -1,22 +1,20 @@
 source common.sh
 
+clearStore
+
 # Instantiate.
-drvPath=$($nixinstantiate substitutes.nix)
+drvPath=$($nixinstantiate simple.nix)
 echo "derivation is $drvPath"
 
 # Find the output path.
 outPath=$($nixstore -qvv "$drvPath")
 echo "output path is $outPath"
 
-regSub() {
-    (echo $1 && echo "" && echo $2 && echo 3 && echo $outPath && echo Hallo && echo Wereld && echo 0) | $nixstore --register-substitutes
-}
-
-# Register a substitute for the output path.
-regSub $outPath $(pwd)/substituter.sh
+echo $outPath > $TEST_ROOT/sub-paths
 
+export NIX_SUBSTITUTERS=$(pwd)/substituter.sh
 
 $nixstore -rvv "$drvPath"
 
 text=$(cat "$outPath"/hello)
-if test "$text" != "Hallo Wereld"; then exit 1; fi
+if test "$text" != "Hallo Wereld"; then echo "wrong substitute output: $text"; exit 1; fi
diff --git a/tests/substitutes2.nix.in b/tests/substitutes2.nix.in
deleted file mode 100644
index 8ade1ba11674..000000000000
--- a/tests/substitutes2.nix.in
+++ /dev/null
@@ -1,6 +0,0 @@
-derivation {
-  name = "substitutes-2";
-  system = "@system@";
-  builder = "@shell@";
-  args = ["-e" "-x" ./simple.builder.sh];
-}
\ No newline at end of file
diff --git a/tests/substitutes2.sh b/tests/substitutes2.sh
index 416e815360c2..0bbc13913dac 100644
--- a/tests/substitutes2.sh
+++ b/tests/substitutes2.sh
@@ -1,25 +1,21 @@
 source common.sh
 
+clearStore
+
 # Instantiate.
-drvPath=$($nixinstantiate substitutes2.nix)
+drvPath=$($nixinstantiate simple.nix)
 echo "derivation is $drvPath"
 
 # Find the output path.
 outPath=$($nixstore -qvvvvv "$drvPath")
 echo "output path is $outPath"
 
-regSub() {
-    (echo $1 && echo "" && echo $2 && echo 3 && echo $outPath && echo Hallo && echo Wereld && echo 0) | $nixstore --register-substitutes
-}
-
-# Register a substitute for the output path.
-regSub $outPath $(pwd)/substituter.sh
+echo $outPath > $TEST_ROOT/sub-paths
 
-# Register another substitute for the output path.  This one takes
-# precedence over the previous one.  It will fail.
-regSub $outPath $(pwd)/substituter2.sh
+# First try a substituter that fails, then one that succeeds
+export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh:$(pwd)/substituter.sh
 
 $nixstore -rvv "$drvPath"
 
 text=$(cat "$outPath"/hello)
-if test "$text" != "Hallo Wereld"; then exit 1; fi
+if test "$text" != "Hallo Wereld"; then echo "wrong substitute output: $text"; exit 1; fi