* Fix the `--fallback' switch.
* Fix the substitutes tests.
This commit is contained in:
parent
581fc47783
commit
c6290e42bc
10 changed files with 35 additions and 87 deletions
|
@ -472,6 +472,12 @@ void DerivationGoal::outputsSubstituted()
|
||||||
{
|
{
|
||||||
trace("all outputs substituted (maybe)");
|
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) {
|
if (checkPathValidity(false).size() == 0) {
|
||||||
amDone(true);
|
amDone(true);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -19,8 +19,8 @@ dependencies.sh: dependencies.nix
|
||||||
locking.sh: locking.nix
|
locking.sh: locking.nix
|
||||||
parallel.sh: parallel.nix
|
parallel.sh: parallel.nix
|
||||||
build-hook.sh: build-hook.nix
|
build-hook.sh: build-hook.nix
|
||||||
substitutes.sh: substitutes.nix substituter.nix
|
substitutes.sh: substitutes.nix
|
||||||
substitutes2.sh: substitutes2.nix substituter.nix substituter2.nix
|
substitutes2.sh: substitutes2.nix
|
||||||
fallback.sh: fallback.nix
|
fallback.sh: fallback.nix
|
||||||
|
|
||||||
TESTS = init.sh hash.sh lang.sh simple.sh dependencies.sh locking.sh parallel.sh \
|
TESTS = init.sh hash.sh lang.sh simple.sh dependencies.sh locking.sh parallel.sh \
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
storeExpr=$($TOP/src/nix-instantiate/nix-instantiate fallback.nix)
|
storeExpr=$($TOP/src/nix-instantiate/nix-instantiate fallback.nix)
|
||||||
|
|
||||||
echo "store expr is $storeExpr"
|
echo "store expr is $storeExpr"
|
||||||
|
|
||||||
# Register a non-existant successor (and a nox-existant substitute).
|
outPath=$($TOP/src/nix-store/nix-store -q --fallback "$storeExpr")
|
||||||
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")
|
|
||||||
|
|
||||||
echo "output path is $outPath"
|
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)
|
text=$(cat "$outPath"/hello)
|
||||||
if test "$text" != "Hello World!"; then exit 1; fi
|
if test "$text" != "Hello World!"; then exit 1; fi
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
# Set a PATH (!!! impure).
|
|
||||||
export PATH=/bin:/usr/bin:$PATH
|
|
||||||
|
|
||||||
mkdir $out
|
|
||||||
|
|
||||||
cat > $out/substituter <<EOF
|
|
||||||
#! /bin/sh -ex
|
|
||||||
echo \$*
|
|
||||||
|
|
||||||
case \$* in
|
|
||||||
*aaaa*)
|
|
||||||
echo "Closure([\"\$2\"],[(\"\$2\",[])])" > \$1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
mkdir \$1
|
|
||||||
echo \$3 \$4 > \$1/hello
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
EOF
|
|
||||||
|
|
||||||
chmod +x $out/substituter
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
derivation {
|
|
||||||
name = "substituter";
|
|
||||||
system = "@system@";
|
|
||||||
builder = "@shell@";
|
|
||||||
args = ["-e" "-x" ./substituter.builder.sh];
|
|
||||||
}
|
|
10
tests/substituter.sh
Executable file
10
tests/substituter.sh
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
#! /bin/sh -ex
|
||||||
|
echo $*
|
||||||
|
|
||||||
|
case $* in
|
||||||
|
*)
|
||||||
|
mkdir $1
|
||||||
|
echo $3 $4 > $1/hello
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
derivation {
|
|
||||||
name = "substituter-2";
|
|
||||||
system = "@system@";
|
|
||||||
builder = "@shell@";
|
|
||||||
args = ["-e" "-x" ./substituter2.builder.sh];
|
|
||||||
}
|
|
6
tests/substituter2.builder.sh → tests/substituter2.sh
Normal file → Executable file
6
tests/substituter2.builder.sh → tests/substituter2.sh
Normal file → Executable file
|
@ -8,12 +8,8 @@ cat > $out/substituter <<EOF
|
||||||
echo \$*
|
echo \$*
|
||||||
|
|
||||||
case \$* in
|
case \$* in
|
||||||
*aaaa*)
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
mkdir \$1
|
exit 1
|
||||||
echo Foo \$3 \$4 > \$1/hello
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
EOF
|
EOF
|
|
@ -3,28 +3,18 @@ storeExpr=$($TOP/src/nix-instantiate/nix-instantiate substitutes.nix)
|
||||||
echo "store expr is $storeExpr"
|
echo "store expr is $storeExpr"
|
||||||
|
|
||||||
# Find the output path.
|
# 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"
|
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() {
|
regSub() {
|
||||||
(echo $1 && echo $2 && echo 3 && echo $outPath && echo Hallo && echo Wereld) | $TOP/src/nix-store/nix-store --substitute
|
(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.
|
# 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)
|
text=$(cat "$outPath"/hello)
|
||||||
if test "$text" != "Hallo Wereld"; then exit 1; fi
|
if test "$text" != "Hallo Wereld"; then exit 1; fi
|
||||||
|
|
|
@ -6,37 +6,18 @@ echo "store expr is $storeExpr"
|
||||||
outPath=$($TOP/src/nix-store/nix-store -qvvvvv "$storeExpr")
|
outPath=$($TOP/src/nix-store/nix-store -qvvvvv "$storeExpr")
|
||||||
echo "output path is $outPath"
|
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() {
|
regSub() {
|
||||||
(echo $1 && echo $2 && echo 3 && echo $outPath && echo Hallo && echo Wereld) | $TOP/src/nix-store/nix-store --substitute
|
(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.
|
# 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
|
# Register another substitute for the output path. This one takes
|
||||||
# produce other output.
|
# precedence over the previous one. It will fail.
|
||||||
regSub $outPath $subProgram2
|
regSub $outPath $(pwd)/substituter2.sh
|
||||||
|
|
||||||
|
$TOP/src/nix-store/nix-store -rvv "$storeExpr"
|
||||||
$TOP/src/nix-store/nix-store -rvvvvv "$storeExpr"
|
|
||||||
|
|
||||||
text=$(cat "$outPath"/hello)
|
text=$(cat "$outPath"/hello)
|
||||||
if test "$text" != "Foo Hallo Wereld"; then exit 1; fi
|
if test "$text" != "Hallo Wereld"; then exit 1; fi
|
||||||
|
|
Loading…
Reference in a new issue