From 8052aef4866e236ef0bb5d5675bbae330abb9b9b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 24 Jun 2004 12:56:24 +0000 Subject: [PATCH] * A test for multiple and/or failing substitutes. --- tests/Makefile.am | 9 +++++--- tests/substituter2.builder.sh | 22 +++++++++++++++++++ tests/substituter2.nix.in | 6 ++++++ tests/substitutes.sh | 8 +++++-- tests/substitutes2.sh | 40 +++++++++++++++++++++++++++++++++++ 5 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 tests/substituter2.builder.sh create mode 100644 tests/substituter2.nix.in create mode 100644 tests/substitutes2.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index e4b81d289..dad3f8791 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 000000000..1794500d6 --- /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 < \$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 000000000..34065b00a --- /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 ea214a8a8..7b236249b 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 000000000..33bae3238 --- /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