forked from conan-io/conan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package_manager_test.py
112 lines (100 loc) · 4.58 KB
/
package_manager_test.py
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import platform
import textwrap
import pytest
import six
from conans.test.utils.tools import TestClient
@pytest.mark.tool_apt_get
@pytest.mark.skipif(platform.system() != "Linux", reason="Requires apt")
@pytest.mark.skipif(six.PY2, reason="Does not pass on Py2 with Pytest")
def test_apt_check():
client = TestClient()
client.save({"conanfile.py": textwrap.dedent("""
from conans import ConanFile
from conan.tools.system.package_manager import Apt
class MyPkg(ConanFile):
settings = "arch", "os"
def system_requirements(self):
apt = Apt(self)
not_installed = apt.check(["non-existing1", "non-existing2"])
print("missing:", not_installed)
""")})
client.run("create . test/1.0@ -s:b arch=armv8 -s:h arch=x86")
assert "dpkg-query: no packages found matching non-existing1:i386" in client.out
assert "dpkg-query: no packages found matching non-existing2:i386" in client.out
assert "missing: ['non-existing1', 'non-existing2']" in client.out
@pytest.mark.tool_apt_get
@pytest.mark.skipif(platform.system() != "Linux", reason="Requires apt")
@pytest.mark.skipif(six.PY2, reason="Does not pass on Py2 with Pytest")
def test_build_require():
client = TestClient()
client.save({"tool_require.py": textwrap.dedent("""
from conans import ConanFile
from conan.tools.system.package_manager import Apt
class MyPkg(ConanFile):
settings = "arch", "os"
def system_requirements(self):
apt = Apt(self)
not_installed = apt.check(["non-existing1", "non-existing2"])
print("missing:", not_installed)
""")})
client.run("export tool_require.py tool_require/1.0@")
client.save({"consumer.py": textwrap.dedent("""
from conans import ConanFile
class consumer(ConanFile):
settings = "arch", "os"
tool_requires = "tool_require/1.0"
""")})
client.run("create consumer.py consumer/1.0@ -s:b arch=armv8 -s:h arch=x86 --build=missing")
assert "dpkg-query: no packages found matching non-existing1:arm64" in client.out
assert "dpkg-query: no packages found matching non-existing2:arm64" in client.out
assert "missing: ['non-existing1', 'non-existing2']" in client.out
@pytest.mark.tool_brew
@pytest.mark.skipif(platform.system() != "Darwin", reason="Requires brew")
@pytest.mark.skipif(six.PY2, reason="Does not pass on Py2 with Pytest")
def test_brew_check():
client = TestClient()
client.save({"conanfile.py": textwrap.dedent("""
from conans import ConanFile
from conan.tools.system.package_manager import Brew
class MyPkg(ConanFile):
settings = "arch"
def system_requirements(self):
brew = Brew(self)
not_installed = brew.check(["non-existing1", "non-existing2"])
print("missing:", not_installed)
""")})
client.run("create . test/1.0@")
assert "missing: ['non-existing1', 'non-existing2']" in client.out
@pytest.mark.tool_brew
@pytest.mark.skipif(platform.system() != "Darwin", reason="Requires brew")
@pytest.mark.skip(reason="brew update takes a lot of time")
def test_brew_install_check_mode():
client = TestClient()
client.save({"conanfile.py": textwrap.dedent("""
from conans import ConanFile
from conan.tools.system.package_manager import Brew
class MyPkg(ConanFile):
settings = "arch"
def system_requirements(self):
brew = Brew(self)
brew.install(["non-existing1", "non-existing2"])
""")})
client.run("create . test/1.0@", assert_error=True)
assert "System requirements: 'non-existing1, non-existing2' are missing but " \
"can't install because tools.system.package_manager:mode is 'check'" in client.out
@pytest.mark.tool_brew
@pytest.mark.skipif(platform.system() != "Darwin", reason="Requires brew")
@pytest.mark.skip(reason="brew update takes a lot of time")
def test_brew_install_install_mode():
client = TestClient()
client.save({"conanfile.py": textwrap.dedent("""
from conans import ConanFile
from conan.tools.system.package_manager import Brew
class MyPkg(ConanFile):
settings = "arch"
def system_requirements(self):
brew = Brew(self)
brew.install(["non-existing1", "non-existing2"])
""")})
client.run("create . test/1.0@ -c tools.system.package_manager:mode=install", assert_error=True)
assert "Error: No formulae found in taps." in client.out