* Fix the tests.

This commit is contained in:
Eelco Dolstra 2007-08-13 13:15:02 +00:00
parent 3757ee589f
commit 550ba9ebb4
12 changed files with 67 additions and 63 deletions

View file

@ -2,14 +2,11 @@ TESTS_ENVIRONMENT = $(SHELL) -e
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
locking.sh: locking.nix
parallel.sh: parallel.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
user-envs.sh: user-envs.nix
fixed.sh: fixed.nix
@ -36,11 +33,9 @@ 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.sh \
substitutes2.nix.in substituter2.sh \
substituter.sh substituter2.sh \
gc-concurrent.nix.in gc-concurrent.builder.sh \
gc-concurrent2.nix.in gc-concurrent2.builder.sh \
fallback.nix.in \
user-envs.nix.in user-envs.builder.sh \
fixed.nix.in fixed.builder1.sh fixed.builder2.sh \
gc-runtime.nix.in \

View file

@ -65,3 +65,7 @@ clearProfiles() {
profiles="$NIX_STATE_DIR"/profiles
rm -f $profiles/*
}
clearManifests() {
rm -f $NIX_STATE_DIR/manifests/*
}

View file

@ -1,7 +0,0 @@
derivation {
name = "fall-back";
system = "@system@";
builder = "@shell@";
args = ["-e" "-x" ./simple.builder.sh];
goodPath = "@testPath@";
}

View file

@ -1,15 +1,19 @@
source common.sh
drvPath=$($nixinstantiate fallback.nix)
clearStore
drvPath=$($nixinstantiate simple.nix)
echo "derivation is $drvPath"
outPath=$($nixstore -q --fallback "$drvPath")
echo "output path is $outPath"
# Register a non-existant substitute
(echo $outPath && echo "" && echo $TOP/no-such-program && echo 0 && echo 0) | $nixstore --register-substitutes
# Build with a substitute that fails. This should fail.
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"
text=$(cat "$outPath"/hello)

View file

@ -6,6 +6,7 @@ pullCache () {
}
clearStore
clearManifests
pullCache
drvPath=$($nixinstantiate dependencies.nix)
@ -17,6 +18,7 @@ $nixstore -r $outPath
cat $outPath/input-2/bar
clearStore
clearManifests
pullCache
echo "building $drvPath using substitutes..."
@ -28,4 +30,4 @@ cat $outPath/input-2/bar
test $($nixstore -q --deriver "$outPath") = "$drvPath"
$nixstore -q --deriver $(readLink $outPath/input-2) | grep -q -- "-input-2.drv"
$nixstore --clear-substitutes
clearManifests

View file

@ -1,7 +1,7 @@
echo "PATH=$PATH"
# 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).
export PATH=$goodPath

View file

@ -1,10 +1,19 @@
#! /bin/sh -ex
echo $*
case $* in
*)
mkdir $1
echo $3 $4 > $1/hello
;;
esac
#! /bin/sh -e
echo substituter args: $* >&2
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

View file

@ -1,3 +1,18 @@
#! /bin/sh -ex
echo $*
exit 1
#! /bin/sh -e
echo substituter2 args: $* >&2
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

View file

@ -1,6 +0,0 @@
derivation {
name = "substitutes";
system = "@system@";
builder = "@shell@";
args = ["-e" "-x" ./simple.builder.sh];
}

View file

@ -1,22 +1,20 @@
source common.sh
clearStore
# Instantiate.
drvPath=$($nixinstantiate substitutes.nix)
drvPath=$($nixinstantiate simple.nix)
echo "derivation is $drvPath"
# Find the output path.
outPath=$($nixstore -qvv "$drvPath")
echo "output path is $outPath"
regSub() {
(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
echo $outPath > $TEST_ROOT/sub-paths
export NIX_SUBSTITUTERS=$(pwd)/substituter.sh
$nixstore -rvv "$drvPath"
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

View file

@ -1,6 +0,0 @@
derivation {
name = "substitutes-2";
system = "@system@";
builder = "@shell@";
args = ["-e" "-x" ./simple.builder.sh];
}

View file

@ -1,25 +1,21 @@
source common.sh
clearStore
# Instantiate.
drvPath=$($nixinstantiate substitutes2.nix)
drvPath=$($nixinstantiate simple.nix)
echo "derivation is $drvPath"
# Find the output path.
outPath=$($nixstore -qvvvvv "$drvPath")
echo "output path is $outPath"
regSub() {
(echo $1 && echo "" && echo $2 && echo 3 && echo $outPath && echo Hallo && echo Wereld && echo 0) | $nixstore --register-substitutes
}
echo $outPath > $TEST_ROOT/sub-paths
# Register a substitute for the output path.
regSub $outPath $(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
# First try a substituter that fails, then one that succeeds
export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh:$(pwd)/substituter.sh
$nixstore -rvv "$drvPath"
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