From b90787290df216f511ec296c85390e645ca1e89f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 1 Mar 2006 14:26:03 +0000 Subject: [PATCH] * TDD! Woohoo! --- tests/common.sh.in | 4 ++++ tests/gc.sh | 9 +++++++++ tests/nix-build.sh | 4 +++- tests/nix-pull.sh | 2 +- tests/simple.sh | 5 +++++ 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/tests/common.sh.in b/tests/common.sh.in index 71554af1..403e144e 100644 --- a/tests/common.sh.in +++ b/tests/common.sh.in @@ -32,3 +32,7 @@ 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 + +readLink() { + ls -l "$1" | sed 's/.*->\ //' +} diff --git a/tests/gc.sh b/tests/gc.sh index c8e06109..e1b3a082 100644 --- a/tests/gc.sh +++ b/tests/gc.sh @@ -12,6 +12,15 @@ $nixstore --gc --print-live | grep $outPath $nixstore --gc --print-dead | grep $drvPath if $nixstore --gc --print-dead | grep $outPath; then false; fi +$nixstore --gc --print-dead + +inUse=$(readLink $outPath/input-2) +if $nixstore --delete $inUse; then false; fi +test -e $inUse + +if $nixstore --delete $outPath; then false; fi +test -e $outPath + $NIX_BIN_DIR/nix-collect-garbage # Check that the root and its dependencies haven't been deleted. diff --git a/tests/nix-build.sh b/tests/nix-build.sh index 23f8ce99..22980956 100644 --- a/tests/nix-build.sh +++ b/tests/nix-build.sh @@ -6,7 +6,9 @@ $nixstore --gc test "$(cat $TEST_ROOT/result/foobar)" = FOOBAR # The result should be retained by a GC. -target=$(ls -l $TEST_ROOT/result | sed 's/.*->\ //') +echo A +target=$(readLink $TEST_ROOT/result) +echo B echo target is $target $nixstore --gc test -e $target/foobar diff --git a/tests/nix-pull.sh b/tests/nix-pull.sh index 03dcdb21..ddbe0f97 100644 --- a/tests/nix-pull.sh +++ b/tests/nix-pull.sh @@ -36,6 +36,6 @@ cat $outPath/input-2/bar # Check that the derivers are set properly. test $($nixstore -q --deriver "$outPath") = "$drvPath" -$nixstore -q --deriver $(ls -l $outPath/input-2 | sed 's/.*->\ //') | grep -q -- "-input-2.drv" +$nixstore -q --deriver $(readLink $outPath/input-2) | grep -q -- "-input-2.drv" $nixstore --clear-substitutes diff --git a/tests/simple.sh b/tests/simple.sh index 225e7c52..a2242e34 100644 --- a/tests/simple.sh +++ b/tests/simple.sh @@ -10,3 +10,8 @@ echo "output path is $outPath" text=$(cat "$outPath"/hello) if test "$text" != "Hello World!"; then exit 1; fi + +# Directed delete: $outPath is not reachable from a root, so it should +# be deleteable. +$nixstore --delete $outPath +if test -e $outPath/hello; then false; fi