Commit c1a51162 authored by Christoph Groth's avatar Christoph Groth

add setup.py test, use it when building debian package

parent 632dc6dc
......@@ -47,8 +47,13 @@ Tinyarray requires Python 2.6 or 2.7.
To install, run::
python setup.py build
python setup.py install
python setup.py build
python setup.py install
If `nose <http://nose.readthedocs.org/>`_ is installed, the included tests can
be run with::
python setup.py test
Usage
......
......@@ -6,6 +6,7 @@ Build-Depends: python-all-dev (>= 2.6.6-3), debhelper (>= 7)
Standards-Version: 3.9.1
Vcs-Git: http://git.kwant-project.org/tinyarray/
Homepage: http://kwant-project.org/tinyarray/
X-Python-Version: >= 2.6
Package: python-tinyarray
Architecture: any
......
#!/usr/bin/make -f
# This file was automatically generated by stdeb 0.6.0+git at
# Thu, 01 Aug 2013 14:53:39 +0200
# See https://wiki.debian.org/Python/LibraryStyleGuide
PYTHON2=$(shell pyversions -vr)
%:
dh $@ --with python2 --buildsystem=python_distutils
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
test-python%:
python$* setup.py test
override_dh_auto_test: $(PYTHON2:%=test-python%)
endif
override_dh_auto_clean:
dh_auto_clean
rm -rf build
......@@ -10,10 +10,14 @@
import subprocess
import os
from distutils.core import setup, Extension
import sys
from distutils.core import setup, Extension, Command
from distutils.util import get_platform
from distutils.errors import DistutilsError, DistutilsModuleError
README_FILE = 'README'
STATIC_VERSION_FILE = 'src/version.hh'
TEST_MODULE = 'test_tinyarray.py'
tinyarray_dir = os.path.dirname(os.path.abspath(__file__))
......@@ -89,6 +93,31 @@ def long_description():
return '\n'.join(text)
class test(Command):
description = "run the unit tests"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
try:
from nose.core import run
except ImportError:
raise DistutilsModuleError('nose <http://nose.readthedocs.org/> '
'is needed to run the tests')
self.run_command('build')
major, minor = sys.version_info[:2]
lib_dir = "build/lib.{0}-{1}.{2}".format(get_platform(), major, minor)
print '**************** Tests ****************'
if not run(argv=[__file__, '-v', '-w', lib_dir,
'-w', '../../' + TEST_MODULE]):
raise DistutilsError('at least one of the tests failed')
module = Extension('tinyarray',
language='c++',
sources=['src/arithmetic.cc', 'src/array.cc',
......@@ -107,6 +136,7 @@ def main():
url="http://kwant-project.org/tinyarray/",
license="BSD",
platforms=["Unix", "Linux", "Mac OS-X", "Windows"],
cmdclass={'test': test},
ext_modules=[module])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment