-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_backend_tests.py
executable file
·172 lines (142 loc) · 5.7 KB
/
run_backend_tests.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/usr/bin/env python3
#
# author : Michael Brockus.
# contact: <mailto:michaelbrockus@gmail.com>
# license: Apache 2.0 :http://www.apache.org/licenses/LICENSE-2.0
#
# copyright 2020 The Meson-UI development team
#
import pytest
from mesonui.mesonuilib.utilitylib import OSUtility
from mesonui.mesonuilib.buildsystem import Meson
from mesonui.mesonuilib.backends.qtcreator import QtCreatorBackend
from mesonui.mesonuilib.backends.kdevelop import KDevelopBackend
from mesonui.mesonuilib.backends.gnome import GNOMEBuilderBackend
from mesonui.repository.mesonapi import MesonAPI
from os.path import join as join_paths
from pathlib import Path
import os
class TestMesonBackend:
def test_kdevelop_backend(self):
#
# Setting up tmp test directory
source = Path(join_paths("test-cases", "backends", "01-kdevelop")).resolve()
build = Path(
join_paths("test-cases", "backends", "01-kdevelop", "builddir")
).resolve()
#
# Running Meson command
meson: Meson = Meson(sourcedir=source, builddir=build)
meson.setup(["--backend=ninja"])
api = MesonAPI(sourcedir=source, builddir=build)
ide = KDevelopBackend(api)
ide.generator()
#
# Run asserts to check it is working
assert os.path.exists(join_paths(source, "meson.build"))
assert os.path.exists(join_paths(build, "build.ninja"))
assert os.path.exists(join_paths(build, "meson-info", "intro-projectinfo.json"))
assert os.path.exists(join_paths(build, "compile_commands.json"))
assert os.path.exists(join_paths(build, "basic.kdev4"))
def test_qtcreator_backend(self):
#
# Setting up tmp test directory
source = Path(join_paths("test-cases", "backends", "03-qtcreator"))
build = Path(join_paths("test-cases", "backends", "03-qtcreator", "builddir"))
#
# Running Meson command
meson: Meson = Meson(sourcedir=source, builddir=build)
meson.setup()
api = MesonAPI(sourcedir=source, builddir=build)
ide = QtCreatorBackend(api)
ide.generator()
#
# Run asserts to check it is working
assert os.path.exists(join_paths(source, "meson.build"))
assert os.path.exists(join_paths(build, "build.ninja"))
assert os.path.exists(join_paths(build, "meson-info", "intro-projectinfo.json"))
assert os.path.exists(join_paths(build, "compile_commands.json"))
assert os.path.exists(join_paths(build, "basic.creator"))
assert os.path.exists(join_paths(build, "basic.includes"))
assert os.path.exists(join_paths(build, "basic.files"))
def test_gnome_builder_backend(self):
#
# Setting up tmp test directory
source = Path(join_paths("test-cases", "backends", "04-gnome")).resolve()
build = Path(
join_paths("test-cases", "backends", "04-gnome", "builddir")
).resolve()
#
# Running Meson command
meson: Meson = Meson(sourcedir=source, builddir=build)
meson.setup(["--backend=ninja"])
api = MesonAPI(sourcedir=source, builddir=build)
ide = GNOMEBuilderBackend(api)
ide.generator()
#
# Run asserts to check it is working
assert os.path.exists(join_paths(source, "meson.build"))
assert os.path.exists(join_paths(build, "build.ninja"))
assert os.path.exists(join_paths(build, "compile_commands.json"))
def test_ninja_backend(self, tmpdir):
#
# Setting up tmp test directory
with tmpdir.as_cwd():
pass
tmpdir.chdir()
#
# Running Meson command
meson: Meson = Meson(sourcedir=tmpdir, builddir=(tmpdir / "builddir"))
meson.init(["--language=c"])
meson.setup(["--backend=ninja"])
#
# Run asserts to check it is working
assert tmpdir.join("meson.build").ensure()
assert tmpdir.join("builddir", "build.ninja").ensure()
assert tmpdir.join("builddir", "compile_commands.json").ensure()
@pytest.mark.skipif(
not OSUtility.is_osx(),
reason="Skipping because Xcode backend only works on OSX systems",
)
def test_xcode_backend(self, tmpdir):
#
# Setting up tmp test directory
with tmpdir.as_cwd():
pass
tmpdir.chdir()
#
# Running Meson command
meson: Meson = Meson(sourcedir=tmpdir, builddir=(tmpdir / "builddir"))
meson.init(["--language=c", "--type=executable"])
meson.setup(["--backend=xcode"])
meson.compile()
meson.test()
#
# Run asserts to check it is working
assert tmpdir.join("meson.build").ensure()
assert tmpdir.join("builddir", "build.ninja").ensure()
assert tmpdir.join("builddir", "compile_commands.json").ensure()
assert tmpdir.join(
"builddir", "test-prog.xcodeproj", "project.pbxproj"
).ensure()
@pytest.mark.skipif(
not OSUtility.is_windows(),
reason="Skipping because Visual Studio backend only works on Windows",
)
def test_vs_backend(self, tmpdir):
#
# Setting up tmp test directory
with tmpdir.as_cwd():
pass
tmpdir.chdir()
#
# Running Meson command
meson: Meson = Meson(sourcedir=tmpdir, builddir=(tmpdir / "builddir"))
meson.init(["--language=c"])
meson.setup(["--backend=vs"])
#
# Run asserts to check it is working
assert tmpdir.join("meson.build").ensure()
assert tmpdir.join("builddir", "build.ninja").ensure()
assert tmpdir.join("builddir", "compile_commands.json").ensure()
# TestMesonBackend().test_codeblocks_backend()