buildcache list: do not display duplicate specs (#13758)

fixes #13757
This commit is contained in:
Massimiliano Culpo 2019-11-26 21:24:15 +01:00 committed by Greg Becker
parent 11e3e332bd
commit f6781d65f0
2 changed files with 25 additions and 6 deletions

View file

@ -416,10 +416,8 @@ def listspecs(args):
"""list binary packages available from mirrors"""
specs = bindist.get_specs(args.force)
if args.packages:
pkgs = set(args.packages)
specs = [s for s in specs for p in pkgs if s.satisfies(p)]
display_specs(specs, args, all_headers=True)
else:
constraints = set(args.packages)
specs = [s for s in specs if any(s.satisfies(c) for c in constraints)]
display_specs(specs, args, all_headers=True)

View file

@ -8,11 +8,19 @@
import pytest
import spack.main
import spack.binary_distribution
buildcache = spack.main.SpackCommand('buildcache')
@pytest.fixture()
def mock_get_specs(database, monkeypatch):
specs = database.query_local()
monkeypatch.setattr(
spack.binary_distribution, 'get_specs', lambda x: specs
)
@pytest.mark.skipif(
platform.system().lower() != 'linux',
reason='implementation for MacOS still missing'
@ -20,3 +28,16 @@
@pytest.mark.db
def test_buildcache_preview_just_runs(database):
buildcache('preview', 'mpileaks')
@pytest.mark.skipif(
platform.system().lower() != 'linux',
reason='implementation for MacOS still missing'
)
@pytest.mark.db
@pytest.mark.regression('13757')
def test_buildcache_list_duplicates(mock_get_specs, capsys):
with capsys.disabled():
output = buildcache('list', 'mpileaks', '@2.3')
assert output.count('mpileaks') == 3