diff options
author | Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com> | 2022-05-05 09:04:16 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-05 18:04:16 +0200 |
commit | 011a491b16a71747d811803a3f2ca1de6b367c0f (patch) | |
tree | b41dba8ed8312311f6768bb86323b264195ec3e6 /lib | |
parent | c9714533f36ba4682356f1ea7874403feab78e17 (diff) | |
download | spack-011a491b16a71747d811803a3f2ca1de6b367c0f.tar.gz spack-011a491b16a71747d811803a3f2ca1de6b367c0f.tar.bz2 spack-011a491b16a71747d811803a3f2ca1de6b367c0f.tar.xz spack-011a491b16a71747d811803a3f2ca1de6b367c0f.zip |
package audit: ensure stand-alone test method not include in build-phase testing (#30352)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/audit.py | 18 | ||||
-rw-r--r-- | lib/spack/spack/test/audit.py | 2 |
2 files changed, 20 insertions, 0 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 |