From 5cb6c42088347bf7ba513cdd68b20c91035c7db9 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 1 Mar 2006 13:49:12 +0000 Subject: [PATCH] * Test nix-build. This also tests indirect roots. --- tests/Makefile.am | 4 ++-- tests/init.sh | 2 ++ tests/logging.sh | 1 - tests/nix-build.sh | 17 +++++++++++++++++ tests/nix-pull.sh | 4 +++- 5 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 tests/nix-build.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index 540665ea9..225f780b8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -3,7 +3,7 @@ TESTS_ENVIRONMENT = $(SHELL) -e extra1 = $(shell pwd)/test-tmp/shared simple.sh: simple.nix -dependencies.sh gc.sh nix-push.sh nix-pull.in logging.sh: dependencies.nix +dependencies.sh gc.sh nix-push.sh nix-pull.in logging.sh nix-build.sh: dependencies.nix locking.sh: locking.nix parallel.sh: parallel.nix build-hook.sh: build-hook.nix @@ -16,7 +16,7 @@ user-envs.sh: user-envs.nix TESTS = init.sh hash.sh lang.sh simple.sh dependencies.sh locking.sh parallel.sh \ build-hook.sh substitutes.sh substitutes2.sh fallback.sh nix-push.sh gc.sh \ gc-concurrent.sh verify.sh nix-pull.sh referrers.sh user-envs.sh \ - logging.sh misc.sh + logging.sh nix-build.sh misc.sh XFAIL_TESTS = diff --git a/tests/init.sh b/tests/init.sh index a11d63f75..11e0632a4 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -23,6 +23,7 @@ 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/ +ln -s $TOP/scripts/nix-build $NIX_BIN_DIR/ mkdir $NIX_BIN_DIR/nix ln -s $TOP/scripts/download-using-manifests.pl $NIX_BIN_DIR/nix/ ln -s $TOP/scripts/readmanifest.pm $NIX_BIN_DIR/nix/ @@ -48,6 +49,7 @@ for i in \ $NIX_BIN_DIR/nix/download-using-manifests.pl \ $NIX_BIN_DIR/nix-prefetch-url \ $NIX_BIN_DIR/nix-collect-garbage \ + $NIX_BIN_DIR/nix-build \ ; do echo "$REAL_BIN_DIR" sed < $i > $i.tmp \ diff --git a/tests/logging.sh b/tests/logging.sh index 50808d264..80d186a75 100644 --- a/tests/logging.sh +++ b/tests/logging.sh @@ -1,7 +1,6 @@ source common.sh $nixstore --gc -$nixstore --clear-substitutes # Produce an escaped log file. $nixstore --log-type escapes -r -vv $($nixinstantiate dependencies.nix) 2> $TEST_ROOT/log.esc diff --git a/tests/nix-build.sh b/tests/nix-build.sh new file mode 100644 index 000000000..23f8ce998 --- /dev/null +++ b/tests/nix-build.sh @@ -0,0 +1,17 @@ +source common.sh + +$nixstore --gc + +(cd $TEST_ROOT && $NIX_BIN_DIR/nix-build ../dependencies.nix) +test "$(cat $TEST_ROOT/result/foobar)" = FOOBAR + +# The result should be retained by a GC. +target=$(ls -l $TEST_ROOT/result | sed 's/.*->\ //') +echo target is $target +$nixstore --gc +test -e $target/foobar + +# But now it should be gone. +rm $TEST_ROOT/result +$nixstore --gc +if test -e $target/foobar; then false; fi diff --git a/tests/nix-pull.sh b/tests/nix-pull.sh index 146227b71..03dcdb21d 100644 --- a/tests/nix-pull.sh +++ b/tests/nix-pull.sh @@ -36,4 +36,6 @@ cat $outPath/input-2/bar # Check that the derivers are set properly. test $($nixstore -q --deriver "$outPath") = "$drvPath" -$nixstore -q --deriver $(/bin/ls -l $outPath/input-2 | sed 's/.*->\ //') | grep -q -- "-input-2.drv" +$nixstore -q --deriver $(ls -l $outPath/input-2 | sed 's/.*->\ //') | grep -q -- "-input-2.drv" + +$nixstore --clear-substitutes