From ea402a255f9c03a644d256b0d1443a986a2bbebb Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 19 Mar 2012 01:20:02 +0100 Subject: Replace "make check" with "make installcheck" Ensuring that the tests work from the build tree requires a growing number of nasty hacks. The tests also don't verify that the installed Nix actually works. Thus, the tests now require "make install" to have been run. --- release.nix | 12 ++++++++++++ substitute.mk | 1 + tests/Makefile.am | 6 ++++++ tests/common.sh.in | 13 ++----------- tests/gc-runtime.sh | 4 +--- tests/hash.sh | 2 +- tests/init.sh | 29 ----------------------------- tests/logging.sh | 4 ++-- 8 files changed, 25 insertions(+), 46 deletions(-) diff --git a/release.nix b/release.nix index cc17bf552..1e72f8046 100644 --- a/release.nix +++ b/release.nix @@ -79,6 +79,12 @@ let --with-dbd-sqlite=${perlPackages.DBDSQLite}/lib/perl5/site_perl --enable-gc ''; + + installCheckPhase = '' + make installcheck + ''; + + postPhases = [ "installCheckPhase" ]; }; @@ -101,6 +107,12 @@ let --with-dbd-sqlite=${perlPackages.DBDSQLite}/lib/perl5/site_perl ''; + installCheckPhase = '' + make installcheck + ''; + + postPhases = [ "installCheckPhase" ]; + lcovFilter = [ "*/boost/*" "*-tab.*" ]; # We call `dot', and even though we just use it to diff --git a/substitute.mk b/substitute.mk index 3f2f367ff..9009b4249 100644 --- a/substitute.mk +++ b/substitute.mk @@ -5,6 +5,7 @@ -e "s^@extra1\@^$(extra1)^g" \ -e "s^@prefix\@^$(prefix)^g" \ -e "s^@bindir\@^$(bindir)^g" \ + -e "s^@datadir\@^$(datadir)^g" \ -e "s^@sysconfdir\@^$(sysconfdir)^g" \ -e "s^@localstatedir\@^$(localstatedir)^g" \ -e "s^@datadir\@^$(datadir)^g" \ diff --git a/tests/Makefile.am b/tests/Makefile.am index d60226fd2..f44caa4b3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -40,3 +40,9 @@ EXTRA_DIST = $(TESTS) \ import-derivation.nix \ $(wildcard lang/*.nix) $(wildcard lang/*.exp) $(wildcard lang/*.exp.xml) $(wildcard lang/*.flags) $(wildcard lang/dir*/*.nix) \ common.sh.in + +# Hacky. +check-am: + @echo "Warning: Nix has no 'make check'. Please install Nix and run 'make installcheck' instead." + +installcheck: check-TESTS diff --git a/tests/common.sh.in b/tests/common.sh.in index 316562f67..0f46e5f4e 100644 --- a/tests/common.sh.in +++ b/tests/common.sh.in @@ -1,9 +1,6 @@ set -e -export top_srcdir="@abs_top_srcdir@" -export top_builddir="@abs_top_builddir@" - -export TOP=$(pwd)/.. +datadir="@datadir@" export TEST_ROOT=$(pwd)/test-tmp export NIX_STORE_DIR @@ -17,18 +14,12 @@ export NIX_LOG_DIR=$TEST_ROOT/var/log/nix export NIX_STATE_DIR=$TEST_ROOT/var/nix export NIX_DB_DIR=$TEST_ROOT/db export NIX_CONF_DIR=$TEST_ROOT/etc -export NIX_BIN_DIR=$TEST_ROOT/bin -export NIX_LIBEXEC_DIR=$TEST_ROOT/bin export NIX_MANIFESTS_DIR=$TEST_ROOT/var/nix/manifests -export NIX_ROOT_FINDER= -export NIX_PATH=nix=$TOP/corepkgs export SHARED=$TEST_ROOT/shared -export PATH=$NIX_BIN_DIR:$TOP/scripts:$PATH +export PATH=@bindir@:$PATH export NIX_BUILD_HOOK= -export PERL=perl -export PERL5LIB=$TOP/perl/lib:$PERL5LIB export dot=@dot@ export xmllint="@xmllint@" export xmlflags="@xmlflags@" diff --git a/tests/gc-runtime.sh b/tests/gc-runtime.sh index df662bd0e..a44195756 100644 --- a/tests/gc-runtime.sh +++ b/tests/gc-runtime.sh @@ -26,9 +26,7 @@ echo PID=$child nix-env -p $profiles/test -e gc-runtime nix-env -p $profiles/test --delete-generations old -cp $TOP/scripts/find-runtime-roots.pl $TEST_ROOT/foo.pl -chmod +x $TEST_ROOT/foo.pl -NIX_ROOT_FINDER=$TEST_ROOT/foo.pl nix-store --gc +nix-store --gc kill -- -$child diff --git a/tests/hash.sh b/tests/hash.sh index de18028ea..d659bbe34 100644 --- a/tests/hash.sh +++ b/tests/hash.sh @@ -46,7 +46,7 @@ chmod +x $TEST_ROOT/hash-path/hello try2 md5 "20f3ffe011d4cfa7d72bfabef7882836" # Mtime and other bits don't. -touch -r $TOP $TEST_ROOT/hash-path/hello +touch -r . $TEST_ROOT/hash-path/hello chmod 744 $TEST_ROOT/hash-path/hello try2 md5 "20f3ffe011d4cfa7d72bfabef7882836" diff --git a/tests/init.sh b/tests/init.sh index 777f95f77..37480f52b 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -16,20 +16,6 @@ mkdir "$NIX_STATE_DIR" mkdir "$NIX_DB_DIR" mkdir "$NIX_CONF_DIR" -mkdir $NIX_BIN_DIR -ln -s $TOP/src/nix-store/nix-store $NIX_BIN_DIR/ -ln -s $TOP/src/nix-instantiate/nix-instantiate $NIX_BIN_DIR/ -ln -s $TOP/src/nix-hash/nix-hash $NIX_BIN_DIR/ -ln -s $TOP/src/nix-env/nix-env $NIX_BIN_DIR/ -ln -s $TOP/src/nix-worker/nix-worker $NIX_BIN_DIR/ -ln -s $TOP/src/bsdiff-*/bsdiff $NIX_BIN_DIR/ -ln -s $TOP/src/bsdiff-*/bspatch $NIX_BIN_DIR/ -ln -s $TOP/scripts/nix-prefetch-url $NIX_BIN_DIR/ -ln -s $TOP/scripts/nix-build $NIX_BIN_DIR/ -ln -s $TOP/scripts/nix-pull $NIX_BIN_DIR/ -mkdir -p $NIX_BIN_DIR/nix/substituters -ln -s $TOP/scripts/copy-from-other-stores.pl $NIX_BIN_DIR/nix/substituters - cat > "$NIX_CONF_DIR"/nix.conf < $NIX_BIN_DIR/nix/substituters/download-using-manifests.pl < $TEST_ROOT/log.esc # Convert it to an XML representation. -$TOP/src/nix-log2xml/nix-log2xml < $TEST_ROOT/log.esc > $TEST_ROOT/log.xml +nix-log2xml < $TEST_ROOT/log.esc > $TEST_ROOT/log.xml # Is this well-formed XML? if test "$xmllint" != "false"; then @@ -16,7 +16,7 @@ fi # Convert to HTML. if test "$xsltproc" != "false"; then - (cd $TOP/src/nix-log2xml && $xsltproc mark-errors.xsl - | $xsltproc log2html.xsl -) < $TEST_ROOT/log.xml > $TEST_ROOT/log.html + (cd $datadir/nix/log2html && $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... -- cgit v1.2.3