summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Volkl <valentin.volkl@cern.ch>2021-05-20 21:16:46 +0200
committerGitHub <noreply@github.com>2021-05-20 19:16:46 +0000
commitb27ccd524e19775695b4aa2cfa3c0b90a80e56ad (patch)
treeb5d9383a808f064002947683c49aa091ca7b3f46
parent1d10245fd427adec65ef6fc0ed6ba0dd93cfd4b5 (diff)
downloadspack-b27ccd524e19775695b4aa2cfa3c0b90a80e56ad.tar.gz
spack-b27ccd524e19775695b4aa2cfa3c0b90a80e56ad.tar.bz2
spack-b27ccd524e19775695b4aa2cfa3c0b90a80e56ad.tar.xz
spack-b27ccd524e19775695b4aa2cfa3c0b90a80e56ad.zip
versions: do not drop 2.0.X if 2.0 is a declared version in the package (#23217)
-rw-r--r--lib/spack/spack/cmd/versions.py7
-rw-r--r--lib/spack/spack/test/cmd/versions.py29
2 files changed, 30 insertions, 6 deletions
diff --git a/lib/spack/spack/cmd/versions.py b/lib/spack/spack/cmd/versions.py
index c124ed37bc..ec808e0e89 100644
--- a/lib/spack/spack/cmd/versions.py
+++ b/lib/spack/spack/cmd/versions.py
@@ -12,7 +12,7 @@ import llnl.util.tty as tty
import spack.cmd.common.arguments as arguments
import spack.repo
-from spack.version import VersionList, ver
+from spack.version import ver, infinity_versions
description = "list available versions of a package"
section = "packaging"
@@ -66,7 +66,10 @@ def versions(parser, args):
if args.new:
if sys.stdout.isatty():
tty.msg('New remote versions (not yet checksummed):')
- highest_safe_version = VersionList(safe_versions).highest_numeric()
+ numeric_safe_versions = list(filter(
+ lambda v: str(v) not in infinity_versions,
+ safe_versions))
+ highest_safe_version = max(numeric_safe_versions)
remote_versions = set([ver(v) for v in set(fetched_versions)
if v > highest_safe_version])
else:
diff --git a/lib/spack/spack/test/cmd/versions.py b/lib/spack/spack/test/cmd/versions.py
index 0d6f53833c..97f1745085 100644
--- a/lib/spack/spack/test/cmd/versions.py
+++ b/lib/spack/spack/test/cmd/versions.py
@@ -6,6 +6,7 @@
import pytest
from spack.main import SpackCommand
+from spack.version import Version
versions = SpackCommand('versions')
@@ -37,12 +38,32 @@ def test_remote_versions_only():
versions('--remote', 'zlib')
-@pytest.mark.maybeslow
@pytest.mark.usefixtures('mock_packages')
-def test_new_versions_only():
+def test_new_versions_only(monkeypatch):
"""Test a package for which new versions should be available."""
-
- versions('--new', 'brillig')
+ from spack.pkg.builtin.mock.brillig import Brillig
+
+ def mock_fetch_remote_versions(*args, **kwargs):
+ mock_remote_versions = {
+ # new version, we expect this to be in output:
+ Version('99.99.99'): {},
+ # some packages use '3.2' equivalently to '3.2.0'
+ # thus '3.2.1' is considered to be a new version
+ # and expected in the output also
+ Version('3.2.1'): {}, # new version, we expect this to be in output
+ Version('3.2'): {},
+ Version('1.0.0'): {},
+ }
+ return mock_remote_versions
+ mock_versions = {
+ # already checksummed versions:
+ Version('3.2'): {},
+ Version('1.0.0'): {},
+ }
+ monkeypatch.setattr(Brillig, 'versions', mock_versions)
+ monkeypatch.setattr(Brillig, 'fetch_remote_versions', mock_fetch_remote_versions)
+ v = versions('--new', 'brillig')
+ assert(v.strip(' \n\t') == "99.99.99\n 3.2.1")
@pytest.mark.maybeslow