diff options
author | alalazo <massimiliano.culpo@googlemail.com> | 2016-10-23 19:02:46 +0200 |
---|---|---|
committer | alalazo <massimiliano.culpo@googlemail.com> | 2016-10-23 19:02:46 +0200 |
commit | fa3f07c0929ef2beedb3746226d3f826f613e9cc (patch) | |
tree | 7aeef6faaca9cd1a65aab04d5297d41b2434c1f2 | |
parent | ebbbed166e6dae8f75a7afae013dfa994f8c11db (diff) | |
download | spack-fa3f07c0929ef2beedb3746226d3f826f613e9cc.tar.gz spack-fa3f07c0929ef2beedb3746226d3f826f613e9cc.tar.bz2 spack-fa3f07c0929ef2beedb3746226d3f826f613e9cc.tar.xz spack-fa3f07c0929ef2beedb3746226d3f826f613e9cc.zip |
CMakePackage, AutotoolsPackage : added default behavior on check
-rw-r--r-- | lib/spack/spack/package.py | 33 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/hdf5/package.py | 3 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/lzo/package.py | 4 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/qhull/package.py | 3 |
4 files changed, 33 insertions, 10 deletions
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 99796104a5..9483f370dd 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -1055,6 +1055,27 @@ class PackageBase(object): mkdirp(self.prefix.lib) mkdirp(self.prefix.man1) + def _if_make_target_execute(self, target): + try: + # Check if we have a makefile + file = [x for x in ('Makefile', 'makefile') if os.path.exists(x)] + file = file.pop() + except IndexError: + tty.msg('No Makefile found in the build directory') + return + + # Check if 'target' is in the makefile + regex = re.compile('^' + target + ':') + with open(file, 'r') as f: + matches = [line for line in f.readlines() if regex.match(line)] + + if not matches: + tty.msg('Target \'' + target + ':\' not found in Makefile') + return + + # Execute target + inspect.getmodule(self).make(target) + def _get_needed_resources(self): resources = [] # Select the resources that are needed for this build @@ -1747,6 +1768,10 @@ class AutotoolsPackage(PackageBase): except AttributeError: tty.msg('Skipping default sanity checks [method `check` not implemented]') # NOQA: ignore=E501 + def check(self): + self._if_make_target_execute('test') + self._if_make_target_execute('check') + # This will be used as a registration decorator in user # packages, if need be PackageBase.sanity_check('install')(PackageBase.sanity_check_prefix) @@ -1814,10 +1839,14 @@ class CMakePackage(PackageBase): def _run_default_function(self): try: fn = getattr(self, 'check') - tty.msg('Trying default sanity checks [check]') + tty.msg('Trying default build sanity checks [check]') fn() except AttributeError: - tty.msg('Skipping default sanity checks [method `check` not implemented]') # NOQA: ignore=E501 + tty.msg('Skipping default build sanity checks [method `check` not implemented]') # NOQA: ignore=E501 + + def check(self): + with working_dir(self.build_directory()): + self._if_make_target_execute('test') PackageBase.sanity_check('install')(PackageBase.sanity_check_prefix) diff --git a/var/spack/repos/builtin/packages/hdf5/package.py b/var/spack/repos/builtin/packages/hdf5/package.py index c92ed284bb..cbb7501034 100644 --- a/var/spack/repos/builtin/packages/hdf5/package.py +++ b/var/spack/repos/builtin/packages/hdf5/package.py @@ -144,7 +144,8 @@ class Hdf5(AutotoolsPackage): return ["--with-zlib=%s" % spec['zlib'].prefix] + extra_args def check(self): - "Build and run a small program to test the installed HDF5 library" + super(Hdf5, self).check() + # Build and run a small program to test the installed HDF5 library spec = self.spec print("Checking HDF5 installation...") checkdir = "spack-check" diff --git a/var/spack/repos/builtin/packages/lzo/package.py b/var/spack/repos/builtin/packages/lzo/package.py index 05229b6a62..e9c98842f4 100644 --- a/var/spack/repos/builtin/packages/lzo/package.py +++ b/var/spack/repos/builtin/packages/lzo/package.py @@ -42,7 +42,3 @@ class Lzo(AutotoolsPackage): '--disable-dependency-tracking', '--enable-shared' ] - - def check(self): - make('check') - make('test') diff --git a/var/spack/repos/builtin/packages/qhull/package.py b/var/spack/repos/builtin/packages/qhull/package.py index 3816b377eb..4456c16bd2 100644 --- a/var/spack/repos/builtin/packages/qhull/package.py +++ b/var/spack/repos/builtin/packages/qhull/package.py @@ -44,6 +44,3 @@ class Qhull(CMakePackage): url="http://www.qhull.org/download/qhull-2012.1-src.tgz") depends_on('cmake@2.6:', type='build') - - def check(self): - make('test') |