From e48bd8c8b50e48db297e49fb325a94e854d6bdad Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 1 Mar 2006 13:25:08 +0000 Subject: * Add a test for nix-log2xml. --- tests/Makefile.am | 8 +++----- tests/common.sh.in | 2 ++ tests/dependencies.sh | 2 +- tests/gc-concurrent.sh | 5 ++++- tests/gc.sh | 5 ++++- tests/logging.sh | 24 ++++++++++++++++++++++++ 6 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 tests/logging.sh (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index dc753e781bf6..540665ea9ef0 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 ca5ef5ecc89b..cd0ebf2cf717 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 cc912f8ef6ca..434027e461fe 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 5004a6e4e270..446e79f138a6 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 afbda953eadc..36b09593de62 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 000000000000..096c743fd178 --- /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 "
  • .*.*echo FOO" $TEST_ROOT/log.html +fi -- cgit 1.4.1