1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# Copyright 2013-2023 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)
import pytest
from spack.main import SpackCommand
from spack.version import Version
versions = SpackCommand("versions")
def test_safe_only_versions():
"""Only test the safe versions of a package.
(Using the deprecated command line argument)
"""
versions("--safe-only", "zlib")
def test_safe_versions():
"""Only test the safe versions of a package."""
versions("--safe", "zlib")
@pytest.mark.maybeslow
def test_remote_versions():
"""Test a package for which remote versions should be available."""
versions("zlib")
@pytest.mark.maybeslow
def test_remote_versions_only():
"""Test a package for which remote versions should be available."""
versions("--remote", "zlib")
@pytest.mark.usefixtures("mock_packages")
def test_new_versions_only(monkeypatch):
"""Test a package for which new versions should be available."""
from spack.pkg.builtin.mock.brillig import Brillig # type: ignore[import]
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
def test_no_versions():
"""Test a package for which no remote versions are available."""
versions("converge")
@pytest.mark.maybeslow
def test_no_unchecksummed_versions():
"""Test a package for which no unchecksummed versions are available."""
versions("bzip2")
@pytest.mark.maybeslow
def test_versions_no_url():
"""Test a package with versions but without a ``url`` attribute."""
versions("graphviz")
@pytest.mark.maybeslow
def test_no_versions_no_url():
"""Test a package without versions or a ``url`` attribute."""
versions("opengl")
|