about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-03-01T14·26+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-03-01T14·26+0000
commitb90787290df216f511ec296c85390e645ca1e89f (patch)
treec269893e2d19f6bac41bce4fbd77b3c5f1b09812
parent089c41a0c2ecf91c55495547a5462d75f36be5f4 (diff)
* TDD! Woohoo!
-rw-r--r--tests/common.sh.in4
-rw-r--r--tests/gc.sh9
-rw-r--r--tests/nix-build.sh4
-rw-r--r--tests/nix-pull.sh2
-rw-r--r--tests/simple.sh5
5 files changed, 22 insertions, 2 deletions
diff --git a/tests/common.sh.in b/tests/common.sh.in
index 71554af109a5..403e144e2dac 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 c8e06109d1f6..e1b3a082046c 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 23f8ce99875f..22980956be69 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 03dcdb21d506..ddbe0f97f32b 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 225e7c522498..a2242e34e8c7 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