summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2019-11-26 21:24:15 +0100
committerGreg Becker <becker33@llnl.gov>2019-11-26 13:24:15 -0700
commitf6781d65f0cfa142c515aa969790816e574b03a6 (patch)
treedcb61f6613d0306b4aea152f8c872043d6fd603c
parent11e3e332bd4f8e01ada2c361cf0461f558b7d9e5 (diff)
downloadspack-f6781d65f0cfa142c515aa969790816e574b03a6.tar.gz
spack-f6781d65f0cfa142c515aa969790816e574b03a6.tar.bz2
spack-f6781d65f0cfa142c515aa969790816e574b03a6.tar.xz
spack-f6781d65f0cfa142c515aa969790816e574b03a6.zip
buildcache list: do not display duplicate specs (#13758)
fixes #13757
-rw-r--r--lib/spack/spack/cmd/buildcache.py8
-rw-r--r--lib/spack/spack/test/cmd/buildcache.py23
2 files changed, 25 insertions, 6 deletions
diff --git a/lib/spack/spack/cmd/buildcache.py b/lib/spack/spack/cmd/buildcache.py
index ee09a33f39..112949c338 100644
--- a/lib/spack/spack/cmd/buildcache.py
+++ b/lib/spack/spack/cmd/buildcache.py
@@ -416,11 +416,9 @@ 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:
- display_specs(specs, args, all_headers=True)
+ 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)
def getkeys(args):
diff --git a/lib/spack/spack/test/cmd/buildcache.py b/lib/spack/spack/test/cmd/buildcache.py
index 2c4f351d86..28f0fb9aec 100644
--- a/lib/spack/spack/test/cmd/buildcache.py
+++ b/lib/spack/spack/test/cmd/buildcache.py
@@ -8,11 +8,19 @@ import platform
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 @@ buildcache = spack.main.SpackCommand('buildcache')
@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