From 482f60d1d37d8d18ff62318c23a72808ceacd99e Mon Sep 17 00:00:00 2001
From: alalazo <massimiliano.culpo@googlemail.com>
Date: Sat, 22 Oct 2016 01:03:07 +0200
Subject: [PATCH] packages : moved decorators into AutotoolsPackage and
 CMakePackage

---
 lib/spack/spack/package.py                    | 20 +++++++++++++++++++
 .../builtin/packages/autoconf/package.py      | 11 ++--------
 .../repos/builtin/packages/hdf5/package.py    |  4 +---
 .../repos/builtin/packages/lzo/package.py     |  2 --
 .../repos/builtin/packages/qhull/package.py   |  2 --
 5 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index 91e6b74dbd..75a708de9c 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -1733,6 +1733,16 @@ def build(self, spec, prefix):
     def install(self, spec, prefix):
         inspect.getmodule(self).make('install')
 
+    @PackageBase.sanity_check('build')
+    @PackageBase.on_package_attributes(run_tests=True)
+    def _run_default_function(self):
+        try:
+            fn = getattr(self, 'check')
+            tty.msg('Trying default sanity checks [check]')
+            fn()
+        except AttributeError:
+            tty.msg('Skipping default sanity checks [method `check` not implemented]')  # NOQA: ignore=E501
+
     # This will be used as a registration decorator in user
     # packages, if need be
     PackageBase.sanity_check('install')(PackageBase.sanity_check_prefix)
@@ -1792,6 +1802,16 @@ def install(self, spec, prefix):
         with working_dir(self.wdir()):
             inspect.getmodule(self).make('install')
 
+    @PackageBase.sanity_check('build')
+    @PackageBase.on_package_attributes(run_tests=True)
+    def _run_default_function(self):
+        try:
+            fn = getattr(self, 'check')
+            tty.msg('Trying default sanity checks [check]')
+            fn()
+        except AttributeError:
+            tty.msg('Skipping default sanity checks [method `check` not implemented]')  # NOQA: ignore=E501
+
     PackageBase.sanity_check('install')(PackageBase.sanity_check_prefix)
 
 
diff --git a/var/spack/repos/builtin/packages/autoconf/package.py b/var/spack/repos/builtin/packages/autoconf/package.py
index 5eb7f3347b..b6aba8c03f 100644
--- a/var/spack/repos/builtin/packages/autoconf/package.py
+++ b/var/spack/repos/builtin/packages/autoconf/package.py
@@ -25,10 +25,8 @@
 from spack import *
 
 
-class Autoconf(Package):
-    """
-    Autoconf -- system configuration part of autotools
-    """
+class Autoconf(AutotoolsPackage):
+    """Autoconf -- system configuration part of autotools"""
     homepage = 'https://www.gnu.org/software/autoconf/'
     url = 'http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz'
 
@@ -54,8 +52,3 @@ def setup_dependent_package(self, module, dependent_spec):
                        'ifnames']
         for name in executables:
             setattr(module, name, self._make_executable(name))
-
-    def install(self, spec, prefix):
-        configure("--prefix=%s" % prefix)
-        make()
-        make("install")
diff --git a/var/spack/repos/builtin/packages/hdf5/package.py b/var/spack/repos/builtin/packages/hdf5/package.py
index 6b18aa4ab8..c92ed284bb 100644
--- a/var/spack/repos/builtin/packages/hdf5/package.py
+++ b/var/spack/repos/builtin/packages/hdf5/package.py
@@ -143,9 +143,7 @@ def configure_args(self):
 
         return ["--with-zlib=%s" % spec['zlib'].prefix] + extra_args
 
-    @AutotoolsPackage.sanity_check('install')
-    @AutotoolsPackage.on_package_attributes(run_tests=True)
-    def check_install(self):
+    def check(self):
         "Build and run a small program to test the installed HDF5 library"
         spec = self.spec
         print("Checking HDF5 installation...")
diff --git a/var/spack/repos/builtin/packages/lzo/package.py b/var/spack/repos/builtin/packages/lzo/package.py
index dc8f316a72..05229b6a62 100644
--- a/var/spack/repos/builtin/packages/lzo/package.py
+++ b/var/spack/repos/builtin/packages/lzo/package.py
@@ -43,8 +43,6 @@ def configure_args(self):
             '--enable-shared'
         ]
 
-    @AutotoolsPackage.sanity_check('build')
-    @AutotoolsPackage.on_package_attributes(run_tests=True)
     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 e221bf1552..3816b377eb 100644
--- a/var/spack/repos/builtin/packages/qhull/package.py
+++ b/var/spack/repos/builtin/packages/qhull/package.py
@@ -45,7 +45,5 @@ class Qhull(CMakePackage):
 
     depends_on('cmake@2.6:', type='build')
 
-    @CMakePackage.sanity_check('build')
-    @CMakePackage.on_package_attributes(run_tests=True)
     def check(self):
         make('test')
-- 
GitLab