aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-03-01 13:25:08 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-03-01 13:25:08 +0000
commite48bd8c8b50e48db297e49fb325a94e854d6bdad (patch)
tree87bb3798180f9e098257266623ab23fdf1a9cd0f /tests
parent458820df6cb976e0642c67ca775d8e7095c091f2 (diff)
* Add a test for nix-log2xml.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am8
-rw-r--r--tests/common.sh.in2
-rw-r--r--tests/dependencies.sh2
-rw-r--r--tests/gc-concurrent.sh5
-rw-r--r--tests/gc.sh5
-rw-r--r--tests/logging.sh24
6 files changed, 38 insertions, 8 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index dc753e781..540665ea9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -3,22 +3,20 @@ TESTS_ENVIRONMENT = $(SHELL) -e
extra1 = $(shell pwd)/test-tmp/shared
simple.sh: simple.nix
-dependencies.sh: dependencies.nix
+dependencies.sh gc.sh nix-push.sh nix-pull.in logging.sh: dependencies.nix
locking.sh: locking.nix
parallel.sh: parallel.nix
build-hook.sh: build-hook.nix
substitutes.sh: substitutes.nix
substitutes2.sh: substitutes2.nix
fallback.sh: fallback.nix
-nix-push.sh: dependencies.nix
-nix-pull.sh: dependencies.nix
-gc.sh: dependencies.nix
gc-concurrent.sh: gc-concurrent.nix gc-concurrent2.nix
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 misc.sh
+ gc-concurrent.sh verify.sh nix-pull.sh referrers.sh user-envs.sh \
+ logging.sh misc.sh
XFAIL_TESTS =
diff --git a/tests/common.sh.in b/tests/common.sh.in
index ca5ef5ecc..cd0ebf2cf 100644
--- a/tests/common.sh.in
+++ b/tests/common.sh.in
@@ -22,6 +22,8 @@ export PERL=perl
export TOP=$(pwd)/..
export aterm_bin=@aterm_bin@
export dot=@dot@
+export xmllint="@xmllint@ @xmlflags@"
+export xsltproc="@xsltproc@"
export version=@version@
diff --git a/tests/dependencies.sh b/tests/dependencies.sh
index cc912f8ef..434027e46 100644
--- a/tests/dependencies.sh
+++ b/tests/dependencies.sh
@@ -4,7 +4,7 @@ drvPath=$($nixinstantiate dependencies.nix)
echo "derivation is $drvPath"
-$TOP/src/nix-store/nix-store -q --tree "$drvPath" | grep ' +---.*builder1.sh'
+$nixstore -q --tree "$drvPath" | grep ' +---.*builder1.sh'
# Test Graphviz graph generation.
$nixstore -q --graph "$drvPath" > $TEST_ROOT/graph
diff --git a/tests/gc-concurrent.sh b/tests/gc-concurrent.sh
index 5004a6e4e..446e79f13 100644
--- a/tests/gc-concurrent.sh
+++ b/tests/gc-concurrent.sh
@@ -6,7 +6,8 @@ outPath1=$($nixstore -q $drvPath1)
drvPath2=$($nixinstantiate gc-concurrent2.nix)
outPath2=$($nixstore -q $drvPath2)
-ln -s $drvPath2 "$NIX_STATE_DIR"/gcroots/foo2
+rm -f "$NIX_STATE_DIR"/gcroots/foo
+ln -s $drvPath2 "$NIX_STATE_DIR"/gcroots/foo
# Start build #1 in the background. It starts immediately.
$nixstore -rvv "$drvPath1" &
@@ -35,3 +36,5 @@ cat $outPath1/input-2/bar
# Build #2 should have failed because its derivation got garbage collected.
cat $outPath2/foobar
+
+rm "$NIX_STATE_DIR"/gcroots/foo
diff --git a/tests/gc.sh b/tests/gc.sh
index afbda953e..36b09593d 100644
--- a/tests/gc.sh
+++ b/tests/gc.sh
@@ -4,7 +4,8 @@ drvPath=$($nixinstantiate dependencies.nix)
outPath=$($nixstore -rvv "$drvPath")
# Set a GC root.
-ln -s $outPath "$NIX_STATE_DIR"/gcroots/foo
+rm -f "$NIX_STATE_DIR"/gcroots/foo
+ln -sf $outPath "$NIX_STATE_DIR"/gcroots/foo
$NIX_BIN_DIR/nix-collect-garbage
@@ -14,3 +15,5 @@ cat $outPath/input-2/bar
# Check that the derivation has been GC'd.
if cat $drvPath > /dev/null; then false; fi
+
+rm "$NIX_STATE_DIR"/gcroots/foo
diff --git a/tests/logging.sh b/tests/logging.sh
new file mode 100644
index 000000000..096c743fd
--- /dev/null
+++ b/tests/logging.sh
@@ -0,0 +1,24 @@
+source common.sh
+
+rm -f $NIX_STATE_DIR/var/nix/
+$nixstore --gc
+
+# Produce an escaped log file.
+$nixstore --log-type escapes -r -vv $($nixinstantiate dependencies.nix) 2> $TEST_ROOT/log.esc
+
+# Convert it to an XML representation.
+$TOP/src/nix-log2xml/nix-log2xml < $TEST_ROOT/log.esc > $TEST_ROOT/log.xml
+
+# Is this well-formed XML?
+if test -n "$xmllint"; then
+ $xmllint --noout $TEST_ROOT/log.xml
+fi
+
+# Convert to HTML.
+if test -n "$xsltproc"; then
+ (cd $TOP/src/nix-log2xml && $xsltproc mark-errors.xsl - | $xsltproc log2html.xsl -) < $TEST_ROOT/log.xml > $TEST_ROOT/log.html
+ # Ideally we would check that the generated HTML is valid...
+
+ # A few checks...
+ grep "<li>.*<code>.*echo FOO" $TEST_ROOT/log.html
+fi