mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
* A test for multiple and/or failing substitutes.
This commit is contained in:
parent
66c7f34759
commit
8052aef486
5 changed files with 80 additions and 5 deletions
|
@ -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
|
||||
substitutes.nix.in substituter.nix.in substituter.builder.sh \
|
||||
substituter2.nix.in substituter2.builder.sh
|
||||
|
|
22
tests/substituter2.builder.sh
Normal file
22
tests/substituter2.builder.sh
Normal file
|
@ -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
|
||||
|
6
tests/substituter2.nix.in
Normal file
6
tests/substituter2.nix.in
Normal file
|
@ -0,0 +1,6 @@
|
|||
derivation {
|
||||
name = "substituter-2";
|
||||
system = "@system@";
|
||||
builder = "@shell@";
|
||||
args = ["-e" "-x" ./substituter2.builder.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"
|
||||
|
|
40
tests/substitutes2.sh
Normal file
40
tests/substitutes2.sh
Normal file
|
@ -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
|
Loading…
Reference in a new issue