summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2022-06-08 15:17:37 +0200
committerMassimiliano Culpo <massimiliano.culpo@gmail.com>2022-07-20 08:10:41 +0200
commit2a7a040327b3a8f88de81db965d0d782a13f21a1 (patch)
treec059fceb72a698e90975c9b5f3cf005f9a98b5ca
parent83bf44f2fe03357b2359c47455c2d43d1e37056c (diff)
downloadspack-2a7a040327b3a8f88de81db965d0d782a13f21a1.tar.gz
spack-2a7a040327b3a8f88de81db965d0d782a13f21a1.tar.bz2
spack-2a7a040327b3a8f88de81db965d0d782a13f21a1.tar.xz
spack-2a7a040327b3a8f88de81db965d0d782a13f21a1.zip
bootstrap: account for disabled sources (#31042)
* bootstrap: account for disabled sources Fix a bug introduced in #30192, which effectively skips any prescription on disabled bootstrapping sources. * Add unit test to avoid regression
-rw-r--r--lib/spack/spack/bootstrap.py9
-rw-r--r--lib/spack/spack/test/bootstrap.py17
2 files changed, 22 insertions, 4 deletions
diff --git a/lib/spack/spack/bootstrap.py b/lib/spack/spack/bootstrap.py
index 20668cf077..26080695ed 100644
--- a/lib/spack/spack/bootstrap.py
+++ b/lib/spack/spack/bootstrap.py
@@ -456,9 +456,10 @@ def _make_bootstrapper(conf):
return _bootstrap_methods[btype](conf)
-def _validate_source_is_trusted(conf):
+def source_is_enabled_or_raise(conf):
+ """Raise ValueError if the source is not enabled for bootstrapping"""
trusted, name = spack.config.get('bootstrap:trusted'), conf['name']
- if name not in trusted:
+ if not trusted.get(name, False):
raise ValueError('source is not trusted')
@@ -529,7 +530,7 @@ def ensure_module_importable_or_raise(module, abstract_spec=None):
for current_config in bootstrapping_sources():
with h.forward(current_config['name']):
- _validate_source_is_trusted(current_config)
+ source_is_enabled_or_raise(current_config)
b = _make_bootstrapper(current_config)
if b.try_import(module, abstract_spec):
@@ -571,7 +572,7 @@ def ensure_executables_in_path_or_raise(executables, abstract_spec):
for current_config in bootstrapping_sources():
with h.forward(current_config['name']):
- _validate_source_is_trusted(current_config)
+ source_is_enabled_or_raise(current_config)
b = _make_bootstrapper(current_config)
if b.try_search_path(executables, abstract_spec):
diff --git a/lib/spack/spack/test/bootstrap.py b/lib/spack/spack/test/bootstrap.py
index fcb3e6418e..183f0bc6f4 100644
--- a/lib/spack/spack/test/bootstrap.py
+++ b/lib/spack/spack/test/bootstrap.py
@@ -180,3 +180,20 @@ def test_status_function_find_files(
_, missing = spack.bootstrap.status_message('optional')
assert missing is expected_missing
+
+
+@pytest.mark.regression('31042')
+def test_source_is_disabled(mutable_config):
+ # Get the configuration dictionary of the current bootstrapping source
+ conf = next(iter(spack.bootstrap.bootstrapping_sources()))
+
+ # The source is not explicitly enabled or disabled, so the following
+ # call should raise to skip using it for bootstrapping
+ with pytest.raises(ValueError):
+ spack.bootstrap.source_is_enabled_or_raise(conf)
+
+ # Try to explicitly disable the source and verify that the behavior
+ # is the same as above
+ spack.config.add('bootstrap:trusted:{0}:{1}'.format(conf['name'], False))
+ with pytest.raises(ValueError):
+ spack.bootstrap.source_is_enabled_or_raise(conf)