forked from tarantool/tt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
82 lines (62 loc) · 1.86 KB
/
conftest.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
import os
import platform
import subprocess
import tempfile
import py
import pytest
from utils import create_tt_config
# ######## #
# Fixtures #
# ######## #
def get_tmpdir(request):
tmpdir = py.path.local(tempfile.mkdtemp())
request.addfinalizer(lambda: tmpdir.remove(rec=1))
return str(tmpdir)
@pytest.fixture(scope="session")
def cli_config_dir():
if platform.system() == "Darwin":
return "/usr/local/etc/tarantool"
elif platform.system() == "Linux":
return "/etc/tarantool"
return ""
@pytest.fixture(scope="session")
def session_tmpdir(request):
return get_tmpdir(request)
@pytest.fixture(scope="session")
def tt_cmd(session_tmpdir):
tt_base_path = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
tt_path = os.path.join(session_tmpdir, "tt")
build_env = os.environ.copy()
build_env["TTEXE"] = tt_path
build_env["TT_CLI_BUILD_SSL"] = "static"
process = subprocess.run(["mage", "-v", "build"], cwd=tt_base_path, env=build_env)
assert process.returncode == 0, "Failed to build Tarantool CLI executable"
return tt_path
@pytest.fixture()
def tmpdir_with_cfg(tmpdir):
create_tt_config(tmpdir, "")
return tmpdir
@pytest.fixture(scope="session")
def tmpdir_with_tarantool(tt_cmd, request):
tmpdir = get_tmpdir(request)
init_cmd = [tt_cmd, "init"]
tt_process = subprocess.Popen(
init_cmd,
cwd=tmpdir,
stderr=subprocess.STDOUT,
stdout=subprocess.DEVNULL,
text=True
)
tt_process.wait()
assert tt_process.returncode == 0
init_cmd = [tt_cmd, "install", "tarantool", "--dynamic"]
tt_process = subprocess.Popen(
init_cmd,
cwd=tmpdir,
stderr=subprocess.STDOUT,
stdout=subprocess.DEVNULL,
text=True
)
tt_process.wait()
assert tt_process.returncode == 0
return tmpdir