Old concretizer: prevent unexpected propagation of external config (#20976)
When using an external package with the old concretizer, all dependencies of that external package were severed. This was not performed bidirectionally though, so for an external package W with a dependency on Z, if some other package Y depended on Z, Z could still pull properties (e.g. compiler) from W since it was not severed as a parent dependency. This performs the severing bidirectionally, and adds tests to confirm expected behavior when using config from DAG-adjacent packages during concretization.
This commit is contained in:
@@ -2278,6 +2278,8 @@ def _expand_virtual_packages(self, concretizer):
|
||||
# If replacement is external then trim the dependencies
|
||||
if replacement.external:
|
||||
if (spec._dependencies):
|
||||
for dep in spec.dependencies():
|
||||
del dep._dependents[spec.name]
|
||||
changed = True
|
||||
spec._dependencies = DependencyMap()
|
||||
replacement._dependencies = DependencyMap()
|
||||
|
||||
@@ -925,6 +925,35 @@ def test_compiler_constraint_with_external_package(
|
||||
assert s.external
|
||||
assert s.satisfies(expected)
|
||||
|
||||
@pytest.mark.regression('20976')
|
||||
@pytest.mark.parametrize('compiler,spec_str,expected,xfailold', [
|
||||
('gcc', 'external-common-python %clang',
|
||||
'%clang ^external-common-openssl%gcc ^external-common-gdbm%clang', False),
|
||||
('clang', 'external-common-python',
|
||||
'%clang ^external-common-openssl%clang ^external-common-gdbm%clang', True)
|
||||
])
|
||||
def test_compiler_in_nonbuildable_external_package(
|
||||
self, compiler, spec_str, expected, xfailold
|
||||
):
|
||||
"""Check that the compiler of a non-buildable external package does not
|
||||
spread to other dependencies, unless no other commpiler is specified."""
|
||||
packages_yaml = {
|
||||
'external-common-openssl': {
|
||||
'externals': [
|
||||
{'spec': 'external-common-openssl@1.1.1i%' + compiler,
|
||||
'prefix': '/usr'}
|
||||
],
|
||||
'buildable': False
|
||||
}
|
||||
}
|
||||
spack.config.set('packages', packages_yaml)
|
||||
|
||||
s = Spec(spec_str).concretized()
|
||||
if xfailold and spack.config.get('config:concretizer') == 'original':
|
||||
pytest.xfail('This only works on the ASP-based concretizer')
|
||||
assert s.satisfies(expected)
|
||||
assert 'external-common-perl' not in [d.name for d in s.dependencies()]
|
||||
|
||||
def test_external_packages_have_consistent_hash(self):
|
||||
if spack.config.get('config:concretizer') == 'original':
|
||||
pytest.skip('This tests needs the ASP-based concretizer')
|
||||
|
||||
Reference in New Issue
Block a user