PythonPackage: Let There Be Tests! (#2869)

* Run python setup.py test if --run-tests
* Attempt to import the Python module after installation
* Add testing support to numpy and scipy
* Remove duplicated comments
* Update to new run-tests callback methodology
* Remove unrelated changes for another PR
This commit is contained in:
Adam J. Stewart
2017-03-31 15:39:07 -05:00
committed by Todd Gamblin
parent 3ade829566
commit bc404532ea
6 changed files with 167 additions and 7 deletions

View File

@@ -36,6 +36,18 @@ class PyNumpy(PythonPackage):
homepage = "http://www.numpy.org/"
url = "https://pypi.io/packages/source/n/numpy/numpy-1.9.1.tar.gz"
install_time_test_callbacks = ['install_test', 'import_module_test']
import_modules = [
'numpy', 'numpy.compat', 'numpy.core', 'numpy.distutils', 'numpy.doc',
'numpy.f2py', 'numpy.fft', 'numpy.lib', 'numpy.linalg', 'numpy.ma',
'numpy.matrixlib', 'numpy.polynomial', 'numpy.random', 'numpy.testing',
'numpy.distutils.command', 'numpy.distutils.fcompiler'
]
# FIXME: numpy._build_utils and numpy.core.code_generators failed to import
# FIXME: Is this expected?
version('1.12.0', '33e5a84579f31829bbbba084fe0a4300',
url="https://pypi.io/packages/source/n/numpy/numpy-1.12.0.zip")
version('1.11.2', '03bd7927c314c43780271bf1ab795ebc')
@@ -53,6 +65,10 @@ class PyNumpy(PythonPackage):
depends_on('blas', when='+blas')
depends_on('lapack', when='+lapack')
# Tests require:
# TODO: Add a 'test' deptype
# depends_on('py-nose@1.0.0:', type='test')
def setup_dependent_package(self, module, dependent_spec):
python_version = self.spec['python'].version.up_to(2)
arch = '{0}-{1}'.format(platform.system().lower(), platform.machine())
@@ -132,3 +148,22 @@ def build_args(self, spec, prefix):
args = ['-j', str(make_jobs)]
return args
def test(self):
# `setup.py test` is not supported. Use one of the following
# instead:
#
# - `python runtests.py` (to build and test)
# - `python runtests.py --no-build` (to test installed numpy)
# - `>>> numpy.test()` (run tests for installed numpy
# from within an interpreter)
pass
def install_test(self):
# Change directories due to the following error:
#
# ImportError: Error importing numpy: you should not try to import
# numpy from its source directory; please exit the numpy
# source tree, and relaunch your python interpreter from there.
with working_dir('..'):
python('-c', 'import numpy; numpy.test("full", verbose=2)')