diff options
author | Greg Becker <becker33@llnl.gov> | 2022-02-10 00:10:23 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-10 09:10:23 +0100 |
commit | 130354b867f6800da733e2eb0890384e3bf5057b (patch) | |
tree | 150802e43faf0d2bcfe56743694b3d33e5f20f8e | |
parent | 36ef59bc6798a2c396fe886ca8943d282ea3c248 (diff) | |
download | spack-130354b867f6800da733e2eb0890384e3bf5057b.tar.gz spack-130354b867f6800da733e2eb0890384e3bf5057b.tar.bz2 spack-130354b867f6800da733e2eb0890384e3bf5057b.tar.xz spack-130354b867f6800da733e2eb0890384e3bf5057b.zip |
spack audit: fix spurious failures for target/platform conflicts (#28860)
-rw-r--r-- | lib/spack/spack/audit.py | 15 | ||||
-rw-r--r-- | lib/spack/spack/test/audit.py | 5 | ||||
-rw-r--r-- | var/spack/repos/builtin.mock/packages/unconstrainable-conflict/package.py | 16 |
3 files changed, 31 insertions, 5 deletions
diff --git a/lib/spack/spack/audit.py b/lib/spack/spack/audit.py index df5fd6c86b..8787f520c2 100644 --- a/lib/spack/spack/audit.py +++ b/lib/spack/spack/audit.py @@ -323,10 +323,17 @@ def _unknown_variants_in_directives(pkgs, error_cls): vrn = spack.spec.Spec(conflict) try: vrn.constrain(trigger) - except Exception as e: - msg = 'Generic error in conflict for package "{0}": ' - errors.append(error_cls(msg.format(pkg.name), [str(e)])) - continue + except Exception: + # If one of the conflict/trigger includes a platform and the other + # includes an os or target, the constraint will fail if the current + # platform is not the plataform in the conflict/trigger. Audit the + # conflict and trigger separately in that case. + # When os and target constraints can be created independently of + # the platform, TODO change this back to add an error. + errors.extend(_analyze_variants_in_directive( + pkg, spack.spec.Spec(trigger), + directive='conflicts', error_cls=error_cls + )) errors.extend(_analyze_variants_in_directive( pkg, vrn, directive='conflicts', error_cls=error_cls )) diff --git a/lib/spack/spack/test/audit.py b/lib/spack/spack/test/audit.py index 207e98a7e8..ffc0d5b8d9 100644 --- a/lib/spack/spack/test/audit.py +++ b/lib/spack/spack/test/audit.py @@ -16,7 +16,10 @@ import spack.config # The package use a non existing variant in a depends_on directive (['wrong-variant-in-depends-on'], 'PKG-DIRECTIVES'), # This package has no issues - (['mpileaks'], None) + (['mpileaks'], None), + # This package has a conflict with a trigger which cannot constrain the constraint + # Should not raise an error + (['unconstrainable-conflict'], None), ]) def test_package_audits(packages, failing_check, mock_packages): reports = spack.audit.run_group('packages', pkgs=packages) diff --git a/var/spack/repos/builtin.mock/packages/unconstrainable-conflict/package.py b/var/spack/repos/builtin.mock/packages/unconstrainable-conflict/package.py new file mode 100644 index 0000000000..e869b13b3f --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/unconstrainable-conflict/package.py @@ -0,0 +1,16 @@ +# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +class UnconstrainableConflict(Package): + """Package with a conflict whose trigger cannot constrain its constraint.""" + + homepage = "http://www.example.com" + url = "http://www.example.com/unconstrainable-conflict-1.0.tar.gz" + + version('1.0', '0123456789abcdef0123456789abcdef') + + # Two conflicts so there's always one that is not the current platform + conflicts('target=x86_64', when='platform=darwin') + conflicts('target=aarch64', when='platform=linux') |