diff options
11 files changed, 306 insertions, 8 deletions
diff --git a/lib/spack/spack/test/cmd/dependents.py b/lib/spack/spack/test/cmd/dependents.py index 22a3acd0c3..681b255d05 100644 --- a/lib/spack/spack/test/cmd/dependents.py +++ b/lib/spack/spack/test/cmd/dependents.py @@ -18,17 +18,28 @@ dependents = SpackCommand('dependents') def test_immediate_dependents(mock_packages): out = dependents('libelf') actual = set(re.split(r'\s+', out.strip())) - assert actual == set(['dyninst', 'libdwarf', - 'patch-a-dependency', 'patch-several-dependencies']) + assert actual == set([ + 'dyninst', + 'libdwarf', + 'patch-a-dependency', + 'patch-several-dependencies', + 'quantum-espresso' + ]) def test_transitive_dependents(mock_packages): out = dependents('--transitive', 'libelf') actual = set(re.split(r'\s+', out.strip())) - assert actual == set( - ['callpath', 'dyninst', 'libdwarf', 'mpileaks', 'multivalue-variant', - 'singlevalue-variant-dependent', - 'patch-a-dependency', 'patch-several-dependencies']) + assert actual == set([ + 'callpath', + 'dyninst', + 'libdwarf', + 'mpileaks', + 'multivalue-variant', + 'singlevalue-variant-dependent', + 'patch-a-dependency', 'patch-several-dependencies', + 'quantum-espresso' + ]) @pytest.mark.db diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py index d8d411cb6a..df8d893adc 100644 --- a/lib/spack/spack/test/concretize.py +++ b/lib/spack/spack/test/concretize.py @@ -2,6 +2,8 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys + import pytest import archspec.cpu @@ -683,6 +685,9 @@ class TestConcretize(object): ('py-extension3@1.1 ^python@2.7.11', ['patchelf@0.9'], []), ('py-extension3@1.0 ^python@3.5.1', ['patchelf@0.10'], []), ]) + @pytest.mark.skipif( + sys.version_info[:2] == (3, 5), reason='Known failure with Python3.5' + ) def test_conditional_dependencies(self, spec_str, expected, unexpected): s = Spec(spec_str).concretized() @@ -710,3 +715,143 @@ class TestConcretize(object): for dep, num_patches in patched_deps: assert s[dep].satisfies('patches=*') assert len(s[dep].variants['patches'].value) == num_patches + + @pytest.mark.regression( + '267,303,1781,2310,2632,3628' + ) + @pytest.mark.parametrize('spec_str, expected', [ + # Need to understand that this configuration is possible + # only if we use the +mpi variant, which is not the default + ('fftw ^mpich', ['+mpi']), + # This spec imposes two orthogonal constraints on a dependency, + # one of which is conditional. The original concretizer fail since + # when it applies the first constraint, it sets the unknown variants + # of the dependency to their default values + ('quantum-espresso', ['^fftw@1.0+mpi']), + # This triggers a conditional dependency on ^fftw@1.0 + ('quantum-espresso', ['^openblas']), + # This constructs a constraint for a dependency og the type + # @x.y:x.z where the lower bound is unconditional, the upper bound + # is conditional to having a variant set + ('quantum-espresso', ['^libelf@0.8.12']), + ('quantum-espresso~veritas', ['^libelf@0.8.13']) + ]) + def test_working_around_conflicting_defaults(self, spec_str, expected): + if spack.config.get('config:concretizer') == 'original': + pytest.xfail('Known failure of the original concretizer') + + s = Spec(spec_str).concretized() + + assert s.concrete + for constraint in expected: + assert s.satisfies(constraint) + + @pytest.mark.regression('4635') + @pytest.mark.parametrize('spec_str,expected', [ + ('cmake', ['%clang']), + ('cmake %gcc', ['%gcc']), + ('cmake %clang', ['%clang']) + ]) + def test_external_package_and_compiler_preferences( + self, spec_str, expected + ): + if spack.config.get('config:concretizer') == 'original': + pytest.xfail('Known failure of the original concretizer') + + packages_yaml = { + 'all': { + 'compiler': ['clang', 'gcc'], + }, + 'cmake': { + 'externals': [ + {'spec': 'cmake@3.4.3', 'prefix': '/usr'} + ], + 'buildable': False + } + } + spack.config.set('packages', packages_yaml) + s = Spec(spec_str).concretized() + + assert s.external + for condition in expected: + assert s.satisfies(condition) + + @pytest.mark.regression('5651') + def test_package_with_constraint_not_met_by_external( + self + ): + """Check that if we have an external package A at version X.Y in + packages.yaml, but our spec doesn't allow X.Y as a version, then + a new version of A is built that meets the requirements. + """ + if spack.config.get('config:concretizer') == 'original': + pytest.xfail('Known failure of the original concretizer') + + packages_yaml = { + 'libelf': { + 'externals': [ + {'spec': 'libelf@0.8.13', 'prefix': '/usr'} + ] + } + } + spack.config.set('packages', packages_yaml) + + # quantum-espresso+veritas requires libelf@:0.8.12 + s = Spec('quantum-espresso+veritas').concretized() + assert s.satisfies('^libelf@0.8.12') + assert not s['libelf'].external + + @pytest.mark.regression('9744') + def test_cumulative_version_ranges_with_different_length(self): + if spack.config.get('config:concretizer') == 'original': + pytest.xfail('Known failure of the original concretizer') + + s = Spec('cumulative-vrange-root').concretized() + assert s.concrete + assert s.satisfies('^cumulative-vrange-bottom@2.2') + + @pytest.mark.regression('9937') + @pytest.mark.skipif( + sys.version_info[:2] == (3, 5), reason='Known failure with Python3.5' + ) + def test_dependency_conditional_on_another_dependency_state(self): + root_str = 'variant-on-dependency-condition-root' + dep_str = 'variant-on-dependency-condition-a' + spec_str = '{0} ^{1}'.format(root_str, dep_str) + + s = Spec(spec_str).concretized() + assert s.concrete + assert s.satisfies('^variant-on-dependency-condition-b') + + s = Spec(spec_str + '+x').concretized() + assert s.concrete + assert s.satisfies('^variant-on-dependency-condition-b') + + s = Spec(spec_str + '~x').concretized() + assert s.concrete + assert not s.satisfies('^variant-on-dependency-condition-b') + + @pytest.mark.regression('8082') + @pytest.mark.parametrize('spec_str,expected', [ + ('cmake %gcc', '%gcc'), + ('cmake %clang', '%clang') + ]) + def test_compiler_constraint_with_external_package( + self, spec_str, expected + ): + if spack.config.get('config:concretizer') == 'original': + pytest.xfail('Known failure of the original concretizer') + + packages_yaml = { + 'cmake': { + 'externals': [ + {'spec': 'cmake@3.4.3', 'prefix': '/usr'} + ], + 'buildable': False + } + } + spack.config.set('packages', packages_yaml) + + s = Spec(spec_str).concretized() + assert s.external + assert s.satisfies(expected) diff --git a/var/spack/repos/builtin.mock/packages/cumulative-vrange-bottom/package.py b/var/spack/repos/builtin.mock/packages/cumulative-vrange-bottom/package.py new file mode 100644 index 0000000000..dbbec45497 --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/cumulative-vrange-bottom/package.py @@ -0,0 +1,16 @@ +# Copyright 2013-2020 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 CumulativeVrangeBottom(Package): + """Test that creating cumulative version ranges of the + form X.Y:X works and allows for the selection of all the + versions >= X.Y with major == X + """ + homepage = 'https://www.example.org' + url = 'https://example.org/files/v3.4/cmake-3.4.3.tar.gz' + + version('3.0', '4cb3ff35b2472aae70f542116d616e63') + version('2.2', '4cb3ff35b2472aae70f542116d616e63') + version('2.1', '4cb3ff35b2472aae70f542116d616e63') + version('2.0', '4cb3ff35b2472aae70f542116d616e63') diff --git a/var/spack/repos/builtin.mock/packages/cumulative-vrange-middle/package.py b/var/spack/repos/builtin.mock/packages/cumulative-vrange-middle/package.py new file mode 100644 index 0000000000..7a6d6d4315 --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/cumulative-vrange-middle/package.py @@ -0,0 +1,15 @@ +# Copyright 2013-2020 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 CumulativeVrangeMiddle(Package): + """Test that creating cumulative version ranges of the + form X.Y:X works and allows for the selection of all the + versions >= X.Y with major == X + """ + homepage = 'https://www.example.org' + url = 'https://example.org/files/v3.4/cmake-3.4.3.tar.gz' + + version('1.0', '4cb3ff35b2472aae70f542116d616e63') + + depends_on('cumulative-vrange-bottom@2.1:') diff --git a/var/spack/repos/builtin.mock/packages/cumulative-vrange-root/package.py b/var/spack/repos/builtin.mock/packages/cumulative-vrange-root/package.py new file mode 100644 index 0000000000..8215ceb517 --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/cumulative-vrange-root/package.py @@ -0,0 +1,16 @@ +# Copyright 2013-2020 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 CumulativeVrangeRoot(Package): + """Test that creating cumulative version ranges of the + form X.Y:X works and allows for the selection of all the + versions >= X.Y with major == X + """ + homepage = 'https://www.example.org' + url = 'https://example.org/files/v3.4/cmake-3.4.3.tar.gz' + + version('1.0', '4cb3ff35b2472aae70f542116d616e63') + + depends_on('cumulative-vrange-middle') + depends_on('cumulative-vrange-bottom@:2')
\ No newline at end of file diff --git a/var/spack/repos/builtin.mock/packages/fftw/package.py b/var/spack/repos/builtin.mock/packages/fftw/package.py new file mode 100644 index 0000000000..9adcf1ea0a --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/fftw/package.py @@ -0,0 +1,18 @@ +# Copyright 2013-2020 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 Fftw(Package): + """Used to test that a few problematic concretization + cases with the old concretizer have been solved by the + new ones. + """ + homepage = "http://www.example.com" + url = "http://www.example.com/fftw-1.0.tar.gz" + + version(2.0, 'foobar') + version(1.0, 'foobar') + + variant('mpi', default=False, description='Enable MPI') + + depends_on('mpi', when='+mpi') diff --git a/var/spack/repos/builtin.mock/packages/hdf5/package.py b/var/spack/repos/builtin.mock/packages/hdf5/package.py index 495dbcbaa8..765a2993b8 100644 --- a/var/spack/repos/builtin.mock/packages/hdf5/package.py +++ b/var/spack/repos/builtin.mock/packages/hdf5/package.py @@ -10,6 +10,6 @@ class Hdf5(Package): version(2.3, 'foobarbaz') - variant('mpi', default=True, description='Debug variant') + variant('mpi', default=True, description='Enable mpi') - depends_on('mpi', when='mpi') + depends_on('mpi', when='+mpi') diff --git a/var/spack/repos/builtin.mock/packages/quantum-espresso/package.py b/var/spack/repos/builtin.mock/packages/quantum-espresso/package.py new file mode 100644 index 0000000000..61287ab7c8 --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/quantum-espresso/package.py @@ -0,0 +1,24 @@ +# Copyright 2013-2020 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 QuantumEspresso(Package): + """Used to test that a few problematic concretization + cases with the old concretizer have been solved by the + new ones. + """ + homepage = "http://www.example.com" + url = "http://www.example.com/qe-1.0.tar.gz" + + version(1.0, 'foobar') + + variant('invino', default=True, description='?') + variant('veritas', default=True, description='?') + + depends_on('fftw@:1.0') + depends_on('fftw+mpi', when='+invino') + + depends_on('openblas', when='^fftw@:1') + + depends_on('libelf@0.8.10:') + depends_on('libelf@:0.8.12', when='+veritas') diff --git a/var/spack/repos/builtin.mock/packages/variant-on-dependency-condition-a/package.py b/var/spack/repos/builtin.mock/packages/variant-on-dependency-condition-a/package.py new file mode 100644 index 0000000000..f2687d6043 --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/variant-on-dependency-condition-a/package.py @@ -0,0 +1,18 @@ +# Copyright 2013-2020 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 VariantOnDependencyConditionA(Package): + """Test that dependencies that are conditional on the state of + other dependencies are added correctly, for instance: + + depends_on('A') + depends_on('B', when='^A+x') + """ + + homepage = 'https://www.example.org' + url = 'https://example.org/files/v3.4/cmake-3.4.3.tar.gz' + + version('1.0', '4cb3ff35b2472aae70f542116d616e63') + + variant('x', default=True, description='?') diff --git a/var/spack/repos/builtin.mock/packages/variant-on-dependency-condition-b/package.py b/var/spack/repos/builtin.mock/packages/variant-on-dependency-condition-b/package.py new file mode 100644 index 0000000000..7660a42a8e --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/variant-on-dependency-condition-b/package.py @@ -0,0 +1,15 @@ +# Copyright 2013-2020 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 VariantOnDependencyConditionB(Package): + """Test that dependencies that are conditional on the state of + other dependencies are added correctly, for instance: + + depends_on('A') + depends_on('B', when='^A+x') + """ + homepage = 'https://www.example.org' + url = 'https://example.org/files/v3.4/cmake-3.4.3.tar.gz' + + version('1.0', '4cb3ff35b2472aae70f542116d616e63') diff --git a/var/spack/repos/builtin.mock/packages/variant-on-dependency-condition-root/package.py b/var/spack/repos/builtin.mock/packages/variant-on-dependency-condition-root/package.py new file mode 100644 index 0000000000..c6ea84b8b2 --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/variant-on-dependency-condition-root/package.py @@ -0,0 +1,20 @@ +# Copyright 2013-2020 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 VariantOnDependencyConditionRoot(Package): + """Test that dependencies that are conditional on the state of + other dependencies are added correctly, for instance: + + depends_on('A') + depends_on('B', when='^A+x') + """ + + homepage = 'https://www.example.org' + url = 'https://example.org/files/v3.4/cmake-3.4.3.tar.gz' + + version('1.0', '4cb3ff35b2472aae70f542116d616e63') + + depends_on('variant-on-dependency-condition-a') + depends_on('variant-on-dependency-condition-b', + when='^variant-on-dependency-condition-a+x') |