summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/audit.py18
-rw-r--r--lib/spack/spack/test/audit.py2
-rw-r--r--var/spack/repos/builtin.mock/packages/test-build-callbacks/package.py4
3 files changed, 22 insertions, 2 deletions
diff --git a/lib/spack/spack/audit.py b/lib/spack/spack/audit.py
index 893c7f6aa3..1075822de7 100644
--- a/lib/spack/spack/audit.py
+++ b/lib/spack/spack/audit.py
@@ -277,6 +277,24 @@ package_https_directives = AuditClass(
@package_directives
+def _check_build_test_callbacks(pkgs, error_cls):
+ """Ensure stand-alone test method is not included in build-time callbacks"""
+ errors = []
+ for pkg_name in pkgs:
+ pkg = spack.repo.get(pkg_name)
+ test_callbacks = pkg.build_time_test_callbacks
+
+ if test_callbacks and 'test' in test_callbacks:
+ msg = ('{0} package contains "test" method in '
+ 'build_time_test_callbacks')
+ instr = ('Remove "test" from: [{0}]'
+ .format(', '.join(test_callbacks)))
+ errors.append(error_cls(msg.format(pkg.name), [instr]))
+
+ return errors
+
+
+@package_directives
def _check_patch_urls(pkgs, error_cls):
"""Ensure that patches fetched from GitHub have stable sha256 hashes."""
github_patch_url_re = (
diff --git a/lib/spack/spack/test/audit.py b/lib/spack/spack/test/audit.py
index 6ad986643e..9cb36b5047 100644
--- a/lib/spack/spack/test/audit.py
+++ b/lib/spack/spack/test/audit.py
@@ -17,6 +17,8 @@ import spack.config
(['wrong-variant-in-depends-on'], 'PKG-DIRECTIVES'),
# This package has a GitHub patch URL without full_index=1
(['invalid-github-patch-url'], 'PKG-DIRECTIVES'),
+ # This package has a stand-alone 'test' method in build-time callbacks
+ (['test-build-callbacks'], 'PKG-DIRECTIVES'),
# This package has no issues
(['mpileaks'], None),
# This package has a conflict with a trigger which cannot constrain the constraint
diff --git a/var/spack/repos/builtin.mock/packages/test-build-callbacks/package.py b/var/spack/repos/builtin.mock/packages/test-build-callbacks/package.py
index 1794649215..f3504bd1c1 100644
--- a/var/spack/repos/builtin.mock/packages/test-build-callbacks/package.py
+++ b/var/spack/repos/builtin.mock/packages/test-build-callbacks/package.py
@@ -16,8 +16,8 @@ class TestBuildCallbacks(Package):
version('1.0', '0123456789abcdef0123456789abcdef')
phases = ['build', 'install']
- # set to undefined method
- build_time_test_callbacks = ['undefined-build-test']
+ # Include undefined method (runtime failure) and 'test' (audit failure)
+ build_time_test_callbacks = ['undefined-build-test', 'test']
run_after('build')(Package._run_default_build_time_test_callbacks)
def build(self, spec, prefix):