mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
* Fix the tests.
This commit is contained in:
parent
3757ee589f
commit
550ba9ebb4
12 changed files with 67 additions and 63 deletions
|
@ -2,14 +2,11 @@ TESTS_ENVIRONMENT = $(SHELL) -e
|
||||||
|
|
||||||
extra1 = $(shell pwd)/test-tmp/shared
|
extra1 = $(shell pwd)/test-tmp/shared
|
||||||
|
|
||||||
simple.sh: simple.nix
|
simple.sh substitutes.sh substitutes2.sh fallback.sh: simple.nix
|
||||||
dependencies.sh gc.sh nix-push.sh nix-pull.in logging.sh nix-build.sh install-package.sh check-refs.sh: dependencies.nix
|
dependencies.sh gc.sh nix-push.sh nix-pull.in logging.sh nix-build.sh install-package.sh check-refs.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
|
|
||||||
substitutes2.sh: substitutes2.nix
|
|
||||||
fallback.sh: fallback.nix
|
|
||||||
gc-concurrent.sh: gc-concurrent.nix gc-concurrent2.nix
|
gc-concurrent.sh: gc-concurrent.nix gc-concurrent2.nix
|
||||||
user-envs.sh: user-envs.nix
|
user-envs.sh: user-envs.nix
|
||||||
fixed.sh: fixed.nix
|
fixed.sh: fixed.nix
|
||||||
|
@ -36,11 +33,9 @@ EXTRA_DIST = $(TESTS) \
|
||||||
locking.nix.in locking.builder.sh \
|
locking.nix.in locking.builder.sh \
|
||||||
parallel.nix.in parallel.builder.sh \
|
parallel.nix.in parallel.builder.sh \
|
||||||
build-hook.nix.in build-hook.hook.sh \
|
build-hook.nix.in build-hook.hook.sh \
|
||||||
substitutes.nix.in substituter.sh \
|
substituter.sh substituter2.sh \
|
||||||
substitutes2.nix.in substituter2.sh \
|
|
||||||
gc-concurrent.nix.in gc-concurrent.builder.sh \
|
gc-concurrent.nix.in gc-concurrent.builder.sh \
|
||||||
gc-concurrent2.nix.in gc-concurrent2.builder.sh \
|
gc-concurrent2.nix.in gc-concurrent2.builder.sh \
|
||||||
fallback.nix.in \
|
|
||||||
user-envs.nix.in user-envs.builder.sh \
|
user-envs.nix.in user-envs.builder.sh \
|
||||||
fixed.nix.in fixed.builder1.sh fixed.builder2.sh \
|
fixed.nix.in fixed.builder1.sh fixed.builder2.sh \
|
||||||
gc-runtime.nix.in \
|
gc-runtime.nix.in \
|
||||||
|
|
|
@ -65,3 +65,7 @@ clearProfiles() {
|
||||||
profiles="$NIX_STATE_DIR"/profiles
|
profiles="$NIX_STATE_DIR"/profiles
|
||||||
rm -f $profiles/*
|
rm -f $profiles/*
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearManifests() {
|
||||||
|
rm -f $NIX_STATE_DIR/manifests/*
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
derivation {
|
|
||||||
name = "fall-back";
|
|
||||||
system = "@system@";
|
|
||||||
builder = "@shell@";
|
|
||||||
args = ["-e" "-x" ./simple.builder.sh];
|
|
||||||
goodPath = "@testPath@";
|
|
||||||
}
|
|
|
@ -1,15 +1,19 @@
|
||||||
source common.sh
|
source common.sh
|
||||||
|
|
||||||
drvPath=$($nixinstantiate fallback.nix)
|
clearStore
|
||||||
|
|
||||||
|
drvPath=$($nixinstantiate simple.nix)
|
||||||
echo "derivation is $drvPath"
|
echo "derivation is $drvPath"
|
||||||
|
|
||||||
outPath=$($nixstore -q --fallback "$drvPath")
|
outPath=$($nixstore -q --fallback "$drvPath")
|
||||||
echo "output path is $outPath"
|
echo "output path is $outPath"
|
||||||
|
|
||||||
# Register a non-existant substitute
|
# Build with a substitute that fails. This should fail.
|
||||||
(echo $outPath && echo "" && echo $TOP/no-such-program && echo 0 && echo 0) | $nixstore --register-substitutes
|
export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh
|
||||||
|
if $nixstore -r "$drvPath"; then echo unexpected fallback; exit 1; fi
|
||||||
|
|
||||||
# Build the derivation
|
# Build with a substitute that fails. This should fall back to a source build.
|
||||||
|
export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh
|
||||||
$nixstore -r --fallback "$drvPath"
|
$nixstore -r --fallback "$drvPath"
|
||||||
|
|
||||||
text=$(cat "$outPath"/hello)
|
text=$(cat "$outPath"/hello)
|
||||||
|
|
|
@ -6,6 +6,7 @@ pullCache () {
|
||||||
}
|
}
|
||||||
|
|
||||||
clearStore
|
clearStore
|
||||||
|
clearManifests
|
||||||
pullCache
|
pullCache
|
||||||
|
|
||||||
drvPath=$($nixinstantiate dependencies.nix)
|
drvPath=$($nixinstantiate dependencies.nix)
|
||||||
|
@ -17,6 +18,7 @@ $nixstore -r $outPath
|
||||||
cat $outPath/input-2/bar
|
cat $outPath/input-2/bar
|
||||||
|
|
||||||
clearStore
|
clearStore
|
||||||
|
clearManifests
|
||||||
pullCache
|
pullCache
|
||||||
|
|
||||||
echo "building $drvPath using substitutes..."
|
echo "building $drvPath using substitutes..."
|
||||||
|
@ -28,4 +30,4 @@ cat $outPath/input-2/bar
|
||||||
test $($nixstore -q --deriver "$outPath") = "$drvPath"
|
test $($nixstore -q --deriver "$outPath") = "$drvPath"
|
||||||
$nixstore -q --deriver $(readLink $outPath/input-2) | grep -q -- "-input-2.drv"
|
$nixstore -q --deriver $(readLink $outPath/input-2) | grep -q -- "-input-2.drv"
|
||||||
|
|
||||||
$nixstore --clear-substitutes
|
clearManifests
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
echo "PATH=$PATH"
|
echo "PATH=$PATH"
|
||||||
|
|
||||||
# Verify that the PATH is empty.
|
# Verify that the PATH is empty.
|
||||||
if mkdir foo; then exit 1; fi
|
if mkdir foo 2> /dev/null; then exit 1; fi
|
||||||
|
|
||||||
# Set a PATH (!!! impure).
|
# Set a PATH (!!! impure).
|
||||||
export PATH=$goodPath
|
export PATH=$goodPath
|
||||||
|
|
|
@ -1,10 +1,19 @@
|
||||||
#! /bin/sh -ex
|
#! /bin/sh -e
|
||||||
echo $*
|
echo substituter args: $* >&2
|
||||||
|
|
||||||
case $* in
|
|
||||||
*)
|
|
||||||
mkdir $1
|
|
||||||
echo $3 $4 > $1/hello
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
|
if test $1 = "--query-paths"; then
|
||||||
|
cat $TEST_ROOT/sub-paths
|
||||||
|
elif test $1 = "--query-info"; then
|
||||||
|
shift
|
||||||
|
for i in in $@; do
|
||||||
|
echo $i
|
||||||
|
echo "" # deriver
|
||||||
|
echo 0 # nr of refs
|
||||||
|
done
|
||||||
|
elif test $1 = "--substitute"; then
|
||||||
|
mkdir $2
|
||||||
|
echo "Hallo Wereld" > $2/hello
|
||||||
|
else
|
||||||
|
echo "unknown substituter operation"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
#! /bin/sh -ex
|
#! /bin/sh -e
|
||||||
echo $*
|
echo substituter2 args: $* >&2
|
||||||
exit 1
|
|
||||||
|
if test $1 = "--query-paths"; then
|
||||||
|
cat $TEST_ROOT/sub-paths
|
||||||
|
elif test $1 = "--query-info"; then
|
||||||
|
shift
|
||||||
|
for i in in $@; do
|
||||||
|
echo $i
|
||||||
|
echo "" # deriver
|
||||||
|
echo 0 # nr of refs
|
||||||
|
done
|
||||||
|
elif test $1 = "--substitute"; then
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "unknown substituter operation"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
derivation {
|
|
||||||
name = "substitutes";
|
|
||||||
system = "@system@";
|
|
||||||
builder = "@shell@";
|
|
||||||
args = ["-e" "-x" ./simple.builder.sh];
|
|
||||||
}
|
|
|
@ -1,22 +1,20 @@
|
||||||
source common.sh
|
source common.sh
|
||||||
|
|
||||||
|
clearStore
|
||||||
|
|
||||||
# Instantiate.
|
# Instantiate.
|
||||||
drvPath=$($nixinstantiate substitutes.nix)
|
drvPath=$($nixinstantiate simple.nix)
|
||||||
echo "derivation is $drvPath"
|
echo "derivation is $drvPath"
|
||||||
|
|
||||||
# Find the output path.
|
# Find the output path.
|
||||||
outPath=$($nixstore -qvv "$drvPath")
|
outPath=$($nixstore -qvv "$drvPath")
|
||||||
echo "output path is $outPath"
|
echo "output path is $outPath"
|
||||||
|
|
||||||
regSub() {
|
echo $outPath > $TEST_ROOT/sub-paths
|
||||||
(echo $1 && echo "" && echo $2 && echo 3 && echo $outPath && echo Hallo && echo Wereld && echo 0) | $nixstore --register-substitutes
|
|
||||||
}
|
|
||||||
|
|
||||||
# Register a substitute for the output path.
|
|
||||||
regSub $outPath $(pwd)/substituter.sh
|
|
||||||
|
|
||||||
|
export NIX_SUBSTITUTERS=$(pwd)/substituter.sh
|
||||||
|
|
||||||
$nixstore -rvv "$drvPath"
|
$nixstore -rvv "$drvPath"
|
||||||
|
|
||||||
text=$(cat "$outPath"/hello)
|
text=$(cat "$outPath"/hello)
|
||||||
if test "$text" != "Hallo Wereld"; then exit 1; fi
|
if test "$text" != "Hallo Wereld"; then echo "wrong substitute output: $text"; exit 1; fi
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
derivation {
|
|
||||||
name = "substitutes-2";
|
|
||||||
system = "@system@";
|
|
||||||
builder = "@shell@";
|
|
||||||
args = ["-e" "-x" ./simple.builder.sh];
|
|
||||||
}
|
|
|
@ -1,25 +1,21 @@
|
||||||
source common.sh
|
source common.sh
|
||||||
|
|
||||||
|
clearStore
|
||||||
|
|
||||||
# Instantiate.
|
# Instantiate.
|
||||||
drvPath=$($nixinstantiate substitutes2.nix)
|
drvPath=$($nixinstantiate simple.nix)
|
||||||
echo "derivation is $drvPath"
|
echo "derivation is $drvPath"
|
||||||
|
|
||||||
# Find the output path.
|
# Find the output path.
|
||||||
outPath=$($nixstore -qvvvvv "$drvPath")
|
outPath=$($nixstore -qvvvvv "$drvPath")
|
||||||
echo "output path is $outPath"
|
echo "output path is $outPath"
|
||||||
|
|
||||||
regSub() {
|
echo $outPath > $TEST_ROOT/sub-paths
|
||||||
(echo $1 && echo "" && echo $2 && echo 3 && echo $outPath && echo Hallo && echo Wereld && echo 0) | $nixstore --register-substitutes
|
|
||||||
}
|
|
||||||
|
|
||||||
# Register a substitute for the output path.
|
# First try a substituter that fails, then one that succeeds
|
||||||
regSub $outPath $(pwd)/substituter.sh
|
export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh:$(pwd)/substituter.sh
|
||||||
|
|
||||||
# Register another substitute for the output path. This one takes
|
|
||||||
# precedence over the previous one. It will fail.
|
|
||||||
regSub $outPath $(pwd)/substituter2.sh
|
|
||||||
|
|
||||||
$nixstore -rvv "$drvPath"
|
$nixstore -rvv "$drvPath"
|
||||||
|
|
||||||
text=$(cat "$outPath"/hello)
|
text=$(cat "$outPath"/hello)
|
||||||
if test "$text" != "Hallo Wereld"; then exit 1; fi
|
if test "$text" != "Hallo Wereld"; then echo "wrong substitute output: $text"; exit 1; fi
|
||||||
|
|
Loading…
Reference in a new issue