summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Kuron <mkuron@users.noreply.github.com>2021-02-26 00:42:40 +0100
committerGitHub <noreply@github.com>2021-02-25 15:42:40 -0800
commit44530588628d4a7b12e76b332d03b5b5cab60378 (patch)
tree5293b37c3e4b8af38b7955fff075146dfc258881
parent476444c59244125aed5b1522fdcb33c2cd2f0f9b (diff)
downloadspack-44530588628d4a7b12e76b332d03b5b5cab60378.tar.gz
spack-44530588628d4a7b12e76b332d03b5b5cab60378.tar.bz2
spack-44530588628d4a7b12e76b332d03b5b5cab60378.tar.xz
spack-44530588628d4a7b12e76b332d03b5b5cab60378.zip
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.
-rw-r--r--lib/spack/spack/spec.py2
-rw-r--r--lib/spack/spack/test/concretize.py29
-rw-r--r--var/spack/repos/builtin.mock/packages/external-common-gdbm/package.py13
-rw-r--r--var/spack/repos/builtin.mock/packages/external-common-openssl/package.py14
-rw-r--r--var/spack/repos/builtin.mock/packages/external-common-perl/package.py14
-rw-r--r--var/spack/repos/builtin.mock/packages/external-common-python/package.py15
6 files changed, 87 insertions, 0 deletions
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 42be765a71..19fb91427b 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -2278,6 +2278,8 @@ class Spec(object):
# 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()
diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py
index 913a22432f..f6898e3e03 100644
--- a/lib/spack/spack/test/concretize.py
+++ b/lib/spack/spack/test/concretize.py
@@ -925,6 +925,35 @@ class TestConcretize(object):
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')
diff --git a/var/spack/repos/builtin.mock/packages/external-common-gdbm/package.py b/var/spack/repos/builtin.mock/packages/external-common-gdbm/package.py
new file mode 100644
index 0000000000..0d7d1b602a
--- /dev/null
+++ b/var/spack/repos/builtin.mock/packages/external-common-gdbm/package.py
@@ -0,0 +1,13 @@
+# Copyright 2013-2021 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)
+
+from spack import *
+
+
+class ExternalCommonGdbm(Package):
+ homepage = "http://www.gnu.org.ua/software/gdbm/gdbm.html"
+ url = "https://ftpmirror.gnu.org/gdbm/gdbm-1.18.1.tar.gz"
+
+ version('1.18.1', 'be78e48cdfc1a7ad90efff146dce6cfe')
diff --git a/var/spack/repos/builtin.mock/packages/external-common-openssl/package.py b/var/spack/repos/builtin.mock/packages/external-common-openssl/package.py
new file mode 100644
index 0000000000..e719fa20fc
--- /dev/null
+++ b/var/spack/repos/builtin.mock/packages/external-common-openssl/package.py
@@ -0,0 +1,14 @@
+# Copyright 2013-2021 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)
+
+from spack import *
+
+
+class ExternalCommonOpenssl(Package):
+ homepage = "http://www.openssl.org"
+ url = "http://www.openssl.org/source/openssl-1.1.1i.tar.gz"
+
+ version('1.1.1i', 'be78e48cdfc1a7ad90efff146dce6cfe')
+ depends_on('external-common-perl')
diff --git a/var/spack/repos/builtin.mock/packages/external-common-perl/package.py b/var/spack/repos/builtin.mock/packages/external-common-perl/package.py
new file mode 100644
index 0000000000..a0a702cda0
--- /dev/null
+++ b/var/spack/repos/builtin.mock/packages/external-common-perl/package.py
@@ -0,0 +1,14 @@
+# Copyright 2013-2021 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)
+
+from spack import *
+
+
+class ExternalCommonPerl(Package):
+ homepage = "http://www.perl.org"
+ url = "http://www.cpan.org/src/5.0/perl-5.32.0.tar.gz"
+
+ version('5.32.0', 'be78e48cdfc1a7ad90efff146dce6cfe')
+ depends_on('external-common-gdbm')
diff --git a/var/spack/repos/builtin.mock/packages/external-common-python/package.py b/var/spack/repos/builtin.mock/packages/external-common-python/package.py
new file mode 100644
index 0000000000..900f375d0d
--- /dev/null
+++ b/var/spack/repos/builtin.mock/packages/external-common-python/package.py
@@ -0,0 +1,15 @@
+# Copyright 2013-2021 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)
+
+from spack import *
+
+
+class ExternalCommonPython(Package):
+ homepage = "http://www.python.org"
+ url = "http://www.python.org/ftp/python/3.8.7/Python-3.8.7.tgz"
+
+ version('3.8.7', 'be78e48cdfc1a7ad90efff146dce6cfe')
+ depends_on('external-common-openssl')
+ depends_on('external-common-gdbm')