From c6290e42bc8890e2036013773a98e3551352c91a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 25 Jan 2005 13:00:12 +0000 Subject: [PATCH] * Fix the `--fallback' switch. * Fix the substitutes tests. --- src/libstore/build.cc | 6 ++++ tests/Makefile.am | 4 +-- tests/fallback.sh | 15 +++++---- tests/substituter.builder.sh | 22 ------------- tests/substituter.nix.in | 6 ---- tests/substituter.sh | 10 ++++++ tests/substituter2.nix.in | 6 ---- ...ubstituter2.builder.sh => substituter2.sh} | 6 +--- tests/substitutes.sh | 16 ++-------- tests/substitutes2.sh | 31 ++++--------------- 10 files changed, 35 insertions(+), 87 deletions(-) delete mode 100644 tests/substituter.builder.sh delete mode 100644 tests/substituter.nix.in create mode 100755 tests/substituter.sh delete mode 100644 tests/substituter2.nix.in rename tests/{substituter2.builder.sh => substituter2.sh} (73%) mode change 100644 => 100755 diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 1de50a140..026721f3b 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -472,6 +472,12 @@ void DerivationGoal::outputsSubstituted() { trace("all outputs substituted (maybe)"); + if (nrFailed > 0 && !tryFallback) { + throw Error(format("some substitutes for the outputs of derivation `%1%' failed; try `--fallback'") % drvPath); + } + + nrFailed = 0; + if (checkPathValidity(false).size() == 0) { amDone(true); return; diff --git a/tests/Makefile.am b/tests/Makefile.am index 1e2ad2969..d91b021ca 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -19,8 +19,8 @@ dependencies.sh: dependencies.nix locking.sh: locking.nix parallel.sh: parallel.nix build-hook.sh: build-hook.nix -substitutes.sh: substitutes.nix substituter.nix -substitutes2.sh: substitutes2.nix substituter.nix substituter2.nix +substitutes.sh: substitutes.nix +substitutes2.sh: substitutes2.nix fallback.sh: fallback.nix TESTS = init.sh hash.sh lang.sh simple.sh dependencies.sh locking.sh parallel.sh \ diff --git a/tests/fallback.sh b/tests/fallback.sh index b859d74ee..081e5695f 100644 --- a/tests/fallback.sh +++ b/tests/fallback.sh @@ -1,15 +1,14 @@ storeExpr=$($TOP/src/nix-instantiate/nix-instantiate fallback.nix) - echo "store expr is $storeExpr" -# Register a non-existant successor (and a nox-existant substitute). -suc=$NIX_STORE_DIR/deadbeafdeadbeafdeadbeafdeadbeaf-s.store -(echo $suc && echo $TOP/no-such-program && echo 0) | $TOP/src/nix-store/nix-store --substitute -$TOP/src/nix-store/nix-store --successor $storeExpr $suc - -outPath=$($TOP/src/nix-store/nix-store -qnf --fallback "$storeExpr") - +outPath=$($TOP/src/nix-store/nix-store -q --fallback "$storeExpr") echo "output path is $outPath" +# Register a non-existant substitute +(echo $outPath && echo $TOP/no-such-program && echo 0) | $TOP/src/nix-store/nix-store --substitute + +# Build the derivation +$TOP/src/nix-store/nix-store -r --fallback "$storeExpr" + text=$(cat "$outPath"/hello) if test "$text" != "Hello World!"; then exit 1; fi diff --git a/tests/substituter.builder.sh b/tests/substituter.builder.sh deleted file mode 100644 index c9ce0a08c..000000000 --- a/tests/substituter.builder.sh +++ /dev/null @@ -1,22 +0,0 @@ -# Set a PATH (!!! impure). -export PATH=/bin:/usr/bin:$PATH - -mkdir $out - -cat > $out/substituter < \$1 - ;; - *) - mkdir \$1 - echo \$3 \$4 > \$1/hello - ;; -esac -EOF - -chmod +x $out/substituter - diff --git a/tests/substituter.nix.in b/tests/substituter.nix.in deleted file mode 100644 index 8f9da530c..000000000 --- a/tests/substituter.nix.in +++ /dev/null @@ -1,6 +0,0 @@ -derivation { - name = "substituter"; - system = "@system@"; - builder = "@shell@"; - args = ["-e" "-x" ./substituter.builder.sh]; -} \ No newline at end of file diff --git a/tests/substituter.sh b/tests/substituter.sh new file mode 100755 index 000000000..005e97605 --- /dev/null +++ b/tests/substituter.sh @@ -0,0 +1,10 @@ +#! /bin/sh -ex +echo $* + +case $* in + *) + mkdir $1 + echo $3 $4 > $1/hello + ;; +esac + diff --git a/tests/substituter2.nix.in b/tests/substituter2.nix.in deleted file mode 100644 index 34065b00a..000000000 --- a/tests/substituter2.nix.in +++ /dev/null @@ -1,6 +0,0 @@ -derivation { - name = "substituter-2"; - system = "@system@"; - builder = "@shell@"; - args = ["-e" "-x" ./substituter2.builder.sh]; -} \ No newline at end of file diff --git a/tests/substituter2.builder.sh b/tests/substituter2.sh old mode 100644 new mode 100755 similarity index 73% rename from tests/substituter2.builder.sh rename to tests/substituter2.sh index 1794500d6..84925b944 --- a/tests/substituter2.builder.sh +++ b/tests/substituter2.sh @@ -8,12 +8,8 @@ cat > $out/substituter < \$1/hello + exit 1 ;; esac EOF diff --git a/tests/substitutes.sh b/tests/substitutes.sh index 72703af4a..c0b61288a 100644 --- a/tests/substitutes.sh +++ b/tests/substitutes.sh @@ -3,28 +3,18 @@ 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") +outPath=$($TOP/src/nix-store/nix-store -qvv "$storeExpr") echo "output path is $outPath" -# Build the substitute program. -subProgram=$($TOP/src/nix-store/nix-store -qnf \ - $($TOP/src/nix-instantiate/nix-instantiate substituter.nix))/substituter -echo "substitute program is $subProgram" - regSub() { (echo $1 && echo $2 && 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 $subProgram -$TOP/src/nix-store/nix-store --successor $storeExpr $suc - # Register a substitute for the output path. -regSub $outPath $subProgram +regSub $outPath $(pwd)/substituter.sh -$TOP/src/nix-store/nix-store -rvvvvv "$storeExpr" +$TOP/src/nix-store/nix-store -rvv "$storeExpr" text=$(cat "$outPath"/hello) if test "$text" != "Hallo Wereld"; then exit 1; fi diff --git a/tests/substitutes2.sh b/tests/substitutes2.sh index b38f4c43f..56f2bab37 100644 --- a/tests/substitutes2.sh +++ b/tests/substitutes2.sh @@ -6,37 +6,18 @@ echo "store expr is $storeExpr" outPath=$($TOP/src/nix-store/nix-store -qvvvvv "$storeExpr") echo "output path is $outPath" -# Build the substitute program. -subProgram=$($TOP/src/nix-store/nix-store -qnf \ - $($TOP/src/nix-instantiate/nix-instantiate substituter.nix))/substituter -echo "substitute program is $subProgram" - -# Build the failing substitute program. -subProgram2=$($TOP/src/nix-store/nix-store -qnf \ - $($TOP/src/nix-instantiate/nix-instantiate substituter2.nix))/substituter -echo "failing substitute program is $subProgram2" - regSub() { (echo $1 && echo $2 && 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/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab-s.store -regSub $suc $subProgram -$TOP/src/nix-store/nix-store --successor $storeExpr $suc - -# Register a failing substitute for it (it takes precedence). -regSub $suc $subProgram2 - # Register a substitute for the output path. -regSub $outPath $subProgram +regSub $outPath $(pwd)/substituter.sh -# Register another substitute for the output path. This one will -# produce other output. -regSub $outPath $subProgram2 +# Register another substitute for the output path. This one takes +# precedence over the previous one. It will fail. +regSub $outPath $(pwd)/substituter2.sh - -$TOP/src/nix-store/nix-store -rvvvvv "$storeExpr" +$TOP/src/nix-store/nix-store -rvv "$storeExpr" text=$(cat "$outPath"/hello) -if test "$text" != "Foo Hallo Wereld"; then exit 1; fi +if test "$text" != "Hallo Wereld"; then exit 1; fi