Spack find: fix queries that specify dependencies (#14757)
Fixes #10019 If multiple instances of a package were installed in a single instance of Spack, and they differed in terms of dependencies, then "spack find" would not distinguish specs based on their dependencies. For example if two instances of X were installed, one with Y and one with Z, then "spack find X ^Y" would display both instances of X.
This commit is contained in:
parent
4e32505770
commit
357786ce6b
@ -1254,7 +1254,8 @@ def _query(
|
||||
if not (start_date < inst_date < end_date):
|
||||
continue
|
||||
|
||||
if query_spec is any or rec.spec.satisfies(query_spec):
|
||||
if (query_spec is any or
|
||||
rec.spec.satisfies(query_spec, strict=True)):
|
||||
results.append(rec.spec)
|
||||
|
||||
return results
|
||||
|
@ -729,3 +729,23 @@ def test_query_unused_specs(mutable_database):
|
||||
unused = spack.store.db.unused_specs
|
||||
assert len(unused) == 1
|
||||
assert unused[0].name == 'cmake'
|
||||
|
||||
|
||||
@pytest.mark.regression('10019')
|
||||
def test_query_spec_with_conditional_dependency(mutable_database):
|
||||
# The issue is triggered by having dependencies that are
|
||||
# conditional on a Boolean variant
|
||||
s = spack.spec.Spec('hdf5~mpi')
|
||||
s.concretize()
|
||||
s.package.do_install(fake=True, explicit=True)
|
||||
|
||||
results = spack.store.db.query_local('hdf5 ^mpich')
|
||||
assert not results
|
||||
|
||||
|
||||
@pytest.mark.regression('10019')
|
||||
def test_query_spec_with_non_conditional_virtual_dependency(database):
|
||||
# Ensure the same issue doesn't come up for virtual
|
||||
# dependency that are not conditional on variants
|
||||
results = spack.store.db.query_local('mpileaks ^mpich')
|
||||
assert len(results) == 1
|
||||
|
15
var/spack/repos/builtin.mock/packages/hdf5/package.py
Normal file
15
var/spack/repos/builtin.mock/packages/hdf5/package.py
Normal file
@ -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 Hdf5(Package):
|
||||
homepage = "http://www.llnl.gov"
|
||||
url = "http://www.llnl.gov/hdf5-1.0.tar.gz"
|
||||
|
||||
version(2.3, 'foobarbaz')
|
||||
|
||||
variant('mpi', default=True, description='Debug variant')
|
||||
|
||||
depends_on('mpi', when='mpi')
|
Loading…
Reference in New Issue
Block a user