Skip to content

Commit

Permalink
* TDD! Woohoo!
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Mar 1, 2006
1 parent 089c41a commit b907872
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions tests/common.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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/.*->\ //'
}
9 changes: 9 additions & 0 deletions tests/gc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion tests/nix-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/nix-pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions tests/simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b907872

Please sign in to comment.