summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2024-07-28 16:13:49 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2024-07-29 01:30:14 -0700
commit4a35dec206bf7283a2d69e21d3a95202934e8172 (patch)
treeffe410488e9541761baceae09cebf64050d39dcc /lib
parentc294b9d3b9e18d0976eee2d5594a4dc4926242d1 (diff)
downloadspack-4a35dec206bf7283a2d69e21d3a95202934e8172.tar.gz
spack-4a35dec206bf7283a2d69e21d3a95202934e8172.tar.bz2
spack-4a35dec206bf7283a2d69e21d3a95202934e8172.tar.xz
spack-4a35dec206bf7283a2d69e21d3a95202934e8172.zip
wasi-sdk: add default provider
This was missed in #45394 because we don't run unit tests for package PRs, and `test_all_virtual_packages_have_default_providers`, which would've caught it, is a unit test, not an audit. - [x] add a default provider for `wasi-sdk` in `etc/spack/defaults/packages.yaml` (which we require for all virtuals) - [x] rework `test_all_virtual_packages_have_default_providers` as an audit called `_ensure_all_virtual_packages_have_default_providers` Signed-off-by: Todd Gamblin <tgamblin@llnl.gov>
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/audit.py16
-rw-r--r--lib/spack/spack/test/repo.py13
2 files changed, 16 insertions, 13 deletions
diff --git a/lib/spack/spack/audit.py b/lib/spack/spack/audit.py
index faef15393d..c5e12017e2 100644
--- a/lib/spack/spack/audit.py
+++ b/lib/spack/spack/audit.py
@@ -351,6 +351,22 @@ def _wrongly_named_spec(error_cls):
return errors
+@config_packages
+def _ensure_all_virtual_packages_have_default_providers(error_cls):
+ """All virtual packages must have a default provider explicitly set."""
+ configuration = spack.config.create()
+ defaults = configuration.get("packages", scope="defaults")
+ default_providers = defaults["all"]["providers"]
+ virtuals = spack.repo.PATH.provider_index.providers
+ default_providers_filename = configuration.scopes["defaults"].get_section_filename("packages")
+
+ return [
+ error_cls(f"'{virtual}' must have a default provider in {default_providers_filename}", [])
+ for virtual in virtuals
+ if virtual not in default_providers
+ ]
+
+
def _make_config_error(config_data, summary, error_cls):
s = io.StringIO()
s.write("Occurring in the following file:\n")
diff --git a/lib/spack/spack/test/repo.py b/lib/spack/spack/test/repo.py
index e08d148289..a013078a82 100644
--- a/lib/spack/spack/test/repo.py
+++ b/lib/spack/spack/test/repo.py
@@ -131,19 +131,6 @@ def test_relative_import_spack_packages_as_python_modules(mock_packages):
assert issubclass(Mpileaks, spack.package_base.PackageBase)
-def test_all_virtual_packages_have_default_providers():
- """All virtual packages must have a default provider explicitly set."""
- configuration = spack.config.create()
- defaults = configuration.get("packages", scope="defaults")
- default_providers = defaults["all"]["providers"]
- providers = spack.repo.PATH.provider_index.providers
- default_providers_filename = configuration.scopes["defaults"].get_section_filename("packages")
- for provider in providers:
- assert provider in default_providers, (
- "all providers must have a default in %s" % default_providers_filename
- )
-
-
def test_get_all_mock_packages(mock_packages):
"""Get the mock packages once each too."""
for name in mock_packages.all_package_names():