about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/Makefile.am9
-rw-r--r--tests/substituter2.builder.sh22
-rw-r--r--tests/substituter2.nix.in6
-rw-r--r--tests/substitutes.sh8
-rw-r--r--tests/substitutes2.sh40
5 files changed, 80 insertions, 5 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e4b81d2897a0..dad3f8791368 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -18,9 +18,11 @@ locking.sh: locking.nix
 parallel.sh: parallel.nix
 build-hook.sh: build-hook.nix
 substitutes.sh: substitutes.nix substituter.nix
+substitutes2.sh: substitutes.nix substituter.nix substituter2.nix
 
-TESTS = init.sh simple.sh dependencies.sh locking.sh parallel.sh \
-  build-hook.sh substitutes.sh
+#TESTS = init.sh simple.sh dependencies.sh locking.sh parallel.sh \
+#  build-hook.sh substitutes.sh substitutes2.sh
+TESTS = init.sh substitutes2.sh
 
 XFAIL_TESTS =
 
@@ -32,4 +34,5 @@ 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.nix.in substituter.builder.sh
\ No newline at end of file
+  substitutes.nix.in substituter.nix.in substituter.builder.sh \
+  substituter2.nix.in substituter2.builder.sh
diff --git a/tests/substituter2.builder.sh b/tests/substituter2.builder.sh
new file mode 100644
index 000000000000..1794500d6f6d
--- /dev/null
+++ b/tests/substituter2.builder.sh
@@ -0,0 +1,22 @@
+# Set a PATH (!!! impure).
+export PATH=/bin:/usr/bin:$PATH
+
+mkdir $out
+
+cat > $out/substituter <<EOF
+#! /bin/sh -ex
+echo \$*
+
+case \$* in
+    *aaaa*)
+        exit 1
+        ;;
+    *)
+        mkdir \$1
+        echo Foo \$3 \$4 > \$1/hello
+        ;;
+esac        
+EOF
+
+chmod +x $out/substituter
+
diff --git a/tests/substituter2.nix.in b/tests/substituter2.nix.in
new file mode 100644
index 000000000000..34065b00a6c5
--- /dev/null
+++ b/tests/substituter2.nix.in
@@ -0,0 +1,6 @@
+derivation {
+  name = "substituter-2";
+  system = "@system@";
+  builder = "@shell@";
+  args = ["-e" "-x" ./substituter2.builder.sh];
+}
\ No newline at end of file
diff --git a/tests/substitutes.sh b/tests/substitutes.sh
index ea214a8a8a43..7b236249b190 100644
--- a/tests/substitutes.sh
+++ b/tests/substitutes.sh
@@ -10,13 +10,17 @@ echo "output path is $outPath"
 subExpr=$($TOP/src/nix-instantiate/nix-instantiate substituter.nix)
 echo "store expr is $subExpr"
 
+regSub() {
+    (echo $1 && echo $2 && echo "/substituter" && echo 3 && echo $outPath && echo Hallo && echo Wereld) | $TOP/src/nix-store/nix-store --substitute
+}
+
 # Register a fake successor, and a substitute for it.
 suc=$NIX_STORE_DIR/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-s.store
-(echo $suc && echo $subExpr && echo "/substituter" && echo 3 && echo $outPath && echo Hallo && echo Wereld) | $TOP/src/nix-store/nix-store --substitute
+regSub $suc $subExpr
 $TOP/src/nix-store/nix-store --successor $storeExpr $suc
 
 # Register a substitute for the output path.
-(echo $outPath && echo $subExpr && echo "/substituter" && echo 3 && echo $outPath && echo Hallo && echo Wereld) | $TOP/src/nix-store/nix-store --substitute
+regSub $outPath $subExpr
 
 
 $TOP/src/nix-store/nix-store -rvvvvv "$storeExpr"
diff --git a/tests/substitutes2.sh b/tests/substitutes2.sh
new file mode 100644
index 000000000000..33bae3238fb8
--- /dev/null
+++ b/tests/substitutes2.sh
@@ -0,0 +1,40 @@
+# Instantiate.
+storeExpr=$($TOP/src/nix-instantiate/nix-instantiate substitutes.nix)
+echo "store expr is $storeExpr"
+
+# Find the output path.
+outPath=$($TOP/src/nix-store/nix-store -qvvvvv "$storeExpr")
+echo "output path is $outPath"
+
+# Instantiate the substitute program.
+subExpr=$($TOP/src/nix-instantiate/nix-instantiate substituter.nix)
+echo "store expr is $subExpr"
+
+# Instantiate the failing substitute program.
+subExpr2=$($TOP/src/nix-instantiate/nix-instantiate substituter2.nix)
+echo "store expr is $subExpr2"
+
+regSub() {
+    (echo $1 && echo $2 && echo "/substituter" && echo 3 && echo $outPath && echo Hallo && echo Wereld) | $TOP/src/nix-store/nix-store --substitute
+}
+
+# Register a fake successor, and a substitute for it.
+suc=$NIX_STORE_DIR/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-s.store
+regSub $suc $subExpr
+$TOP/src/nix-store/nix-store --successor $storeExpr $suc
+
+# Register a failing substitute for it (it takes precedence).
+regSub $suc $subExpr2
+
+# Register a substitute for the output path.
+regSub $outPath $subExpr
+
+# Register another substitute for the output path.  This one will
+# produce other output. 
+regSub $outPath $subExpr2
+
+
+$TOP/src/nix-store/nix-store -rvvvvv "$storeExpr"
+
+text=$(cat "$outPath"/hello)
+if test "$text" != "Foo Hallo Wereld"; then exit 1; fi