* Simplification.

This commit is contained in:
Eelco Dolstra 2006-03-01 12:51:18 +00:00
parent a4c63c6e8e
commit 84c4631221
21 changed files with 77 additions and 67 deletions

View file

@ -1,5 +1,7 @@
TESTS_ENVIRONMENT = $(SHELL) -e
extra1 = $(shell pwd)/test-tmp/shared
simple.sh: simple.nix
dependencies.sh: dependencies.nix
locking.sh: locking.nix

View file

@ -2,11 +2,11 @@ source common.sh
export NIX_BUILD_HOOK="build-hook.hook.sh"
drvPath=$($TOP/src/nix-instantiate/nix-instantiate build-hook.nix)
drvPath=$($nixinstantiate build-hook.nix)
echo "derivation is $drvPath"
outPath=$($TOP/src/nix-store/nix-store -quf "$drvPath")
outPath=$($nixstore -quf "$drvPath")
echo "output path is $outPath"

View file

@ -24,3 +24,8 @@ export aterm_bin=@aterm_bin@
export dot=@dot@
export version=@version@
export nixinstantiate=$TOP/src/nix-instantiate/nix-instantiate
export nixstore=$TOP/src/nix-store/nix-store
export nixenv=$TOP/src/nix-env/nix-env
export nixhash=$TOP/src/nix-hash/nix-hash

View file

@ -1,35 +1,35 @@
source common.sh
drvPath=$($TOP/src/nix-instantiate/nix-instantiate dependencies.nix)
drvPath=$($nixinstantiate dependencies.nix)
echo "derivation is $drvPath"
$TOP/src/nix-store/nix-store -q --tree "$drvPath" | grep ' +---.*builder1.sh'
# Test Graphviz graph generation.
$TOP/src/nix-store/nix-store -q --graph "$drvPath" > $TEST_ROOT/graph
$nixstore -q --graph "$drvPath" > $TEST_ROOT/graph
if test -n "$dot"; then
# Does it parse?
$dot < $TEST_ROOT/graph
fi
outPath=$($TOP/src/nix-store/nix-store -rvv "$drvPath")
outPath=$($nixstore -rvv "$drvPath")
# Test Graphviz graph generation.
$TOP/src/nix-store/nix-store -q --graph "$outPath" > $TEST_ROOT/graph
$nixstore -q --graph "$outPath" > $TEST_ROOT/graph
if test -n "$dot"; then
# Does it parse?
$dot < $TEST_ROOT/graph
fi
$TOP/src/nix-store/nix-store -q --tree "$outPath" | grep '+---.*dependencies-input-2'
$nixstore -q --tree "$outPath" | grep '+---.*dependencies-input-2'
echo "output path is $outPath"
text=$(cat "$outPath"/foobar)
if test "$text" != "FOOBAR"; then exit 1; fi
deps=$($TOP/src/nix-store/nix-store -quR "$drvPath")
deps=$($nixstore -quR "$drvPath")
echo "output closure contains $deps"
@ -43,8 +43,8 @@ if echo "$deps" | grep -q "dependencies-input-1"; then exit 1; fi
input2OutPath=$(echo "$deps" | grep "dependencies-input-2")
# The referrers closure of input-2 should include outPath.
$TOP/src/nix-store/nix-store -q --referrers-closure "$input2OutPath" | grep "$outPath"
$nixstore -q --referrers-closure "$input2OutPath" | grep "$outPath"
# Check that the derivers are set properly.
test $($TOP/src/nix-store/nix-store -q --deriver "$outPath") = "$drvPath"
$TOP/src/nix-store/nix-store -q --deriver "$input2OutPath" | grep -q -- "-input-2.drv"
test $($nixstore -q --deriver "$outPath") = "$drvPath"
$nixstore -q --deriver "$input2OutPath" | grep -q -- "-input-2.drv"

View file

@ -1,16 +1,16 @@
source common.sh
drvPath=$($TOP/src/nix-instantiate/nix-instantiate fallback.nix)
drvPath=$($nixinstantiate fallback.nix)
echo "derivation is $drvPath"
outPath=$($TOP/src/nix-store/nix-store -q --fallback "$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) | $TOP/src/nix-store/nix-store --register-substitutes
(echo $outPath && echo "" && echo $TOP/no-such-program && echo 0 && echo 0) | $nixstore --register-substitutes
# Build the derivation
$TOP/src/nix-store/nix-store -r --fallback "$drvPath"
$nixstore -r --fallback "$drvPath"
text=$(cat "$outPath"/hello)
if test "$text" != "Hello World!"; then exit 1; fi

View file

@ -1,19 +1,19 @@
source common.sh
drvPath1=$($TOP/src/nix-instantiate/nix-instantiate gc-concurrent.nix)
outPath1=$($TOP/src/nix-store/nix-store -q $drvPath1)
drvPath1=$($nixinstantiate gc-concurrent.nix)
outPath1=$($nixstore -q $drvPath1)
drvPath2=$($TOP/src/nix-instantiate/nix-instantiate gc-concurrent2.nix)
outPath2=$($TOP/src/nix-store/nix-store -q $drvPath2)
drvPath2=$($nixinstantiate gc-concurrent2.nix)
outPath2=$($nixstore -q $drvPath2)
ln -s $drvPath2 "$NIX_STATE_DIR"/gcroots/foo2
# Start build #1 in the background. It starts immediately.
$TOP/src/nix-store/nix-store -rvv "$drvPath1" &
$nixstore -rvv "$drvPath1" &
pid1=$!
# Start build #2 in the background after 3 seconds.
(sleep 3 && $TOP/src/nix-store/nix-store -rvv "$drvPath2") &
(sleep 3 && $nixstore -rvv "$drvPath2") &
pid2=$!
# Run the garbage collector while the build is running. Note: the GC

View file

@ -1,7 +1,7 @@
source common.sh
drvPath=$($TOP/src/nix-instantiate/nix-instantiate dependencies.nix)
outPath=$($TOP/src/nix-store/nix-store -rvv "$drvPath")
drvPath=$($nixinstantiate dependencies.nix)
outPath=$($nixstore -rvv "$drvPath")
# Set a GC root.
ln -s $outPath "$NIX_STATE_DIR"/gcroots/foo

View file

@ -2,7 +2,7 @@ source common.sh
try () {
echo -n "$2" > $TEST_ROOT/vector
hash=$($TOP/src/nix-hash/nix-hash $EXTRA --flat --type "$1" $TEST_ROOT/vector)
hash=$($nixhash $EXTRA --flat --type "$1" $TEST_ROOT/vector)
if test "$hash" != "$3"; then
echo "hash $1, expected $3, got $hash"
exit 1
@ -28,7 +28,7 @@ try sha256 "abc" "1b8m03r63zqhnjf7l5wnldhh7c134ap5vpj0850ymkq1iyzicy5s"
EXTRA=
try2 () {
hash=$($TOP/src/nix-hash/nix-hash --type "$1" $TEST_ROOT/hash-path)
hash=$($nixhash --type "$1" $TEST_ROOT/hash-path)
if test "$hash" != "$2"; then
echo "hash $1, expected $2, got $hash"
exit 1

View file

@ -18,9 +18,9 @@ mkdir "$NIX_DB_DIR"
mkdir "$NIX_CONF_DIR"
mkdir $NIX_BIN_DIR
ln -s $TOP/src/nix-store/nix-store $NIX_BIN_DIR/
ln -s $TOP/src/nix-instantiate/nix-instantiate $NIX_BIN_DIR/
ln -s $TOP/src/nix-hash/nix-hash $NIX_BIN_DIR/
ln -s $nixstore $NIX_BIN_DIR/
ln -s $nixinstantiate $NIX_BIN_DIR/
ln -s $nixhash $NIX_BIN_DIR/
ln -s $TOP/scripts/nix-prefetch-url $NIX_BIN_DIR/
ln -s $TOP/scripts/nix-collect-garbage $NIX_BIN_DIR/
mkdir $NIX_BIN_DIR/nix
@ -66,7 +66,7 @@ chmod +x tmp
mv tmp $NIX_DATA_DIR/nix/corepkgs/nar/nar.sh
# Initialise the database.
$TOP/src/nix-store/nix-store --init
$nixstore --init
# Did anything happen?
test -e "$NIX_DB_DIR"/validpaths

View file

@ -5,7 +5,7 @@ fail=0
for i in lang/parse-fail-*.nix; do
echo "parsing $i (should fail)";
i=$(basename $i .nix)
if $TOP/src/nix-instantiate/nix-instantiate --parse-only - < lang/$i.nix; then
if $nixinstantiate --parse-only - < lang/$i.nix; then
echo "FAIL: $i shouldn't parse"
fail=1
fi
@ -14,7 +14,7 @@ done
for i in lang/parse-okay-*.nix; do
echo "parsing $i (should succeed)";
i=$(basename $i .nix)
if ! $TOP/src/nix-instantiate/nix-instantiate --parse-only - < lang/$i.nix > lang/$i.ast; then
if ! $nixinstantiate --parse-only - < lang/$i.nix > lang/$i.ast; then
echo "FAIL: $i should parse"
fail=1
fi
@ -27,7 +27,7 @@ done
for i in lang/eval-fail-*.nix; do
echo "evaluating $i (should fail)";
i=$(basename $i .nix)
if $TOP/src/nix-instantiate/nix-instantiate --eval-only - < lang/$i.nix; then
if $nixinstantiate --eval-only - < lang/$i.nix; then
echo "FAIL: $i shouldn't evaluate"
fail=1
fi
@ -36,7 +36,7 @@ done
for i in lang/eval-okay-*.nix; do
echo "evaluating $i (should succeed)";
i=$(basename $i .nix)
if ! $TOP/src/nix-instantiate/nix-instantiate --eval-only - < lang/$i.nix > lang/$i.out; then
if ! $nixinstantiate --eval-only - < lang/$i.nix > lang/$i.out; then
echo "FAIL: $i should evaluate"
fail=1
fi

View file

@ -1,17 +1,17 @@
source common.sh
drvPath=$($TOP/src/nix-instantiate/nix-instantiate locking.nix)
drvPath=$($nixinstantiate locking.nix)
echo "derivation is $drvPath"
for i in 1 2 3 4 5; do
echo "WORKER $i"
$TOP/src/nix-store/nix-store -rvv "$drvPath" &
$nixstore -rvv "$drvPath" &
done
sleep 5
outPath=$($TOP/src/nix-store/nix-store -qvvf "$drvPath")
outPath=$($nixstore -qvvf "$drvPath")
echo "output path is $outPath"

View file

@ -3,10 +3,14 @@ source common.sh
# Tests miscellaneous commands.
# Do all commands have help?
$TOP/src/nix-env/nix-env --help | grep -q install
$TOP/src/nix-store/nix-store --help | grep -q realise
$TOP/src/nix-instantiate/nix-instantiate --help | grep -q eval-only
$TOP/src/nix-hash/nix-hash --help | grep -q base32
$nixenv --help | grep -q install
$nixstore --help | grep -q realise
$nixinstantiate --help | grep -q eval-only
$nixhash --help | grep -q base32
# Can we ask for the version number?
$TOP/src/nix-env/nix-env --version | grep "$version"
$nixenv --version | grep "$version"
# Usage errors.
$nixenv --foo 2>&1 | grep "no operation"
$nixenv -q --foo 2>&1 | grep "unknown flag"

View file

@ -7,7 +7,7 @@ clearStore () {
mkdir "$NIX_STORE_DIR"
rm -rf "$NIX_DB_DIR"
mkdir "$NIX_DB_DIR"
$TOP/src/nix-store/nix-store --init
$nixstore --init
}
pullCache () {
@ -18,11 +18,11 @@ pullCache () {
clearStore
pullCache
drvPath=$($TOP/src/nix-instantiate/nix-instantiate dependencies.nix)
outPath=$($TOP/src/nix-store/nix-store -q $drvPath)
drvPath=$($nixinstantiate dependencies.nix)
outPath=$($nixstore -q $drvPath)
echo "building $outPath using substitutes..."
$TOP/src/nix-store/nix-store -r $outPath
$nixstore -r $outPath
cat $outPath/input-2/bar
@ -30,10 +30,10 @@ clearStore
pullCache
echo "building $drvPath using substitutes..."
$TOP/src/nix-store/nix-store -r $drvPath
$nixstore -r $drvPath
cat $outPath/input-2/bar
# Check that the derivers are set properly.
test $($TOP/src/nix-store/nix-store -q --deriver "$outPath") = "$drvPath"
$TOP/src/nix-store/nix-store -q --deriver $(/bin/ls -l $outPath/input-2 | sed 's/.*->\ //') | grep -q -- "-input-2.drv"
test $($nixstore -q --deriver "$outPath") = "$drvPath"
$nixstore -q --deriver $(/bin/ls -l $outPath/input-2 | sed 's/.*->\ //') | grep -q -- "-input-2.drv"

View file

@ -1,7 +1,7 @@
source common.sh
drvPath=$($TOP/src/nix-instantiate/nix-instantiate dependencies.nix)
outPath=$($TOP/src/nix-store/nix-store -r $drvPath)
drvPath=$($nixinstantiate dependencies.nix)
outPath=$($nixstore -r $drvPath)
echo "pushing $drvPath"

View file

@ -1,10 +1,10 @@
source common.sh
drvPath=$($TOP/src/nix-instantiate/nix-instantiate parallel.nix)
drvPath=$($nixinstantiate parallel.nix)
echo "derivation is $drvPath"
outPath=$($TOP/src/nix-store/nix-store -qfvv -j10000 "$drvPath")
outPath=$($nixstore -qfvv -j10000 "$drvPath")
echo "output path is $outPath"

View file

@ -4,14 +4,14 @@ max=5000
reference=$NIX_STORE_DIR/abcdef
touch $reference
(echo $reference && echo && echo 0) | $TOP/src/nix-store/nix-store --register-validity
(echo $reference && echo && echo 0) | $nixstore --register-validity
echo "registering..."
time for ((n = 0; n < $max; n++)); do
storePath=$NIX_STORE_DIR/$n
touch $storePath
(echo $storePath && echo && echo 1 && echo $reference)
done | $TOP/src/nix-store/nix-store --register-validity
done | $nixstore --register-validity
echo "collecting garbage..."
time $TOP/src/nix-store/nix-store --gc 2> /dev/null
time $nixstore --gc 2> /dev/null

View file

@ -1,10 +1,10 @@
source common.sh
drvPath=$($TOP/src/nix-instantiate/nix-instantiate simple.nix)
drvPath=$($nixinstantiate simple.nix)
echo "derivation is $drvPath"
outPath=$($TOP/src/nix-store/nix-store -rvv "$drvPath")
outPath=$($nixstore -rvv "$drvPath")
echo "output path is $outPath"

View file

@ -1,22 +1,22 @@
source common.sh
# Instantiate.
drvPath=$($TOP/src/nix-instantiate/nix-instantiate substitutes.nix)
drvPath=$($nixinstantiate substitutes.nix)
echo "derivation is $drvPath"
# Find the output path.
outPath=$($TOP/src/nix-store/nix-store -qvv "$drvPath")
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) | $TOP/src/nix-store/nix-store --register-substitutes
(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
$TOP/src/nix-store/nix-store -rvv "$drvPath"
$nixstore -rvv "$drvPath"
text=$(cat "$outPath"/hello)
if test "$text" != "Hallo Wereld"; then exit 1; fi

View file

@ -1,15 +1,15 @@
source common.sh
# Instantiate.
drvPath=$($TOP/src/nix-instantiate/nix-instantiate substitutes2.nix)
drvPath=$($nixinstantiate substitutes2.nix)
echo "derivation is $drvPath"
# Find the output path.
outPath=$($TOP/src/nix-store/nix-store -qvvvvv "$drvPath")
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) | $TOP/src/nix-store/nix-store --register-substitutes
(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.
@ -19,7 +19,7 @@ regSub $outPath $(pwd)/substituter.sh
# precedence over the previous one. It will fail.
regSub $outPath $(pwd)/substituter2.sh
$TOP/src/nix-store/nix-store -rvv "$drvPath"
$nixstore -rvv "$drvPath"
text=$(cat "$outPath"/hello)
if test "$text" != "Hallo Wereld"; then exit 1; fi

View file

@ -1,6 +1,5 @@
source common.sh
nixenv=$TOP/src/nix-env/nix-env
profiles="$NIX_STATE_DIR"/profiles
# Query installed: should be empty.

View file

@ -1,3 +1,3 @@
source common.sh
$TOP/src/nix-store/nix-store --verify
$nixstore --verify