Rely more on pybuild for build-time tests
authorAfif Elghraoui <afif@debian.org>
Mon, 20 Jun 2016 01:12:23 +0000 (18:12 -0700)
committerAfif Elghraoui <afif@debian.org>
Mon, 20 Jun 2016 01:12:23 +0000 (18:12 -0700)
debian/rules

index c0e5f846c153017cf9a2e1a9e8809f116ffc99f2..357ac5218314bc22c0e550875b5053095592e91d 100755 (executable)
@@ -13,7 +13,15 @@ export HTSLIB_LIBRARY_DIR=$(HTSLIBDIR)
 export HTSLIB_INCLUDE_DIR=/usr/include
 
 export PYBUILD_TEST_NOSE=1
-export PYBUILD_TEST_ARGS={dir}/tests
+# pybuild calls nosetests as `python{version} -m nose tests`
+#
+# The "tests" argument (passed by pybuild as shown above) fails,
+# so don't pass anything:
+export PYBUILD_TEST_ARGS=
+# This is how we pass parameters to nose without command-line flags
+export NOSE_WHERE=$(CURDIR)/tests
+export NOSE_VERBOSE=2
+export NOSE_NOCAPTURE=1
 
 # DEB_BUILD_OPTIONS := nocheck
 
@@ -24,15 +32,8 @@ clean: clean-tests
 override_dh_install: clean-tests
        dh_install -Xtest.gtf.gz
 
-override_dh_auto_test:
-       cd tests && make -C pysam_data
-       cd tests/cbcf_data && make
-       # dh_auto_test  # unfortunately this does not work out of the box
-                       # see https://lists.debian.org/debian-python/2015/07/msg00064.html
-                       # thus trying manually with unusual tricks
-       PYBUILD_SYSTEM=custom \
-       PYBUILD_TEST_ARGS="cd tests && if [ {version} = 2.7 ] ; then nosetests -s ; else nosetests3 -s -v ; fi" dh_auto_test || \
-               echo "Ignoring test failures"
+override_dh_auto_test: pysam_data.all cbcf_data.all
+       dh_auto_test
 
 get-orig-source:
        uscan --verbose --force-download --repack --compression xz
@@ -44,8 +45,14 @@ override_dh_auto_clean:
                pysam/config.h \
                samtools/config.h
 
-clean-tests:
-       $(MAKE) -C tests/pysam_data clean
+.PHONY: pysam_data.% cbcf_data.%
+cbcf_data.%:
+       cd tests/$(basename $@) && $(MAKE) $*
+pysam_data.%:
+       cd tests/$(basename $@) && $(MAKE) $*
+
+.PHONY: clean-tests
+clean-tests: pysam_data.clean cbcf_data.clean
        find . -name "*.pyc" -delete
        find . -name "*.pyxbldc" -delete
        find . -name "tmp_*" -delete
@@ -61,5 +68,3 @@ clean-tests:
                tests/__pycache__ \
                pysam/calignmentfile.c \
                pysam/cbcf.c
-
-.PHONY: clean-tests