Debian Codegraph @

tests/meson.build

raw
1 env_tests = environment()
2 env_tests.set('XDG_DATA_DIRS', meson.current_build_dir() / 'share')
3 env_tests.set('G_TEST_SRCDIR', meson.current_source_dir())
4 env_tests.set('G_TEST_BUILDDIR', meson.current_build_dir())
5 env_tests.set('G_DEBUG', 'gc-friendly') # from glib-tap.mk
6
7 if glib_dep.version().version_compare('>= 2.68')
8 test_protocol = 'tap'
9 else
10 test_protocol = 'exitcode'
11 endif
12
13 subdir('dbs')
14 test_permission_db = executable(
15 'test-permission-db',
16 ['test-permission-db.c'] + db_sources,
17 dependencies: [common_deps] + db_deps,
18 include_directories: [common_includes],
19 install: enable_installed_tests,
20 install_dir: installed_tests_dir,
21 )
22 test(
23 'unit/permission-db',
24 test_permission_db,
25 suite: ['unit'],
26 env: env_tests,
27 is_parallel: false,
28 protocol: test_protocol,
29 )
30
31 test_xdp_utils = executable(
32 'test-xdp-utils',
33 'test-xdp-utils.c',
34 xdp_utils_sources,
35 dependencies: [common_deps, xdp_utils_deps],
36 include_directories: [common_includes, xdp_utils_includes],
37 install: enable_installed_tests,
38 install_dir: installed_tests_dir,
39 )
40 test(
41 'unit/xdp-utils',
42 test_xdp_utils,
43 suite: ['unit'],
44 env: env_tests,
45 is_parallel: false,
46 protocol: test_protocol,
47 )
48
49 test_method_info = executable(
50 'test-xdp-method-info',
51 'test-xdp-method-info.c',
52 xdp_method_info_sources,
53 dependencies: [common_deps],
54 include_directories: [common_includes, xdp_utils_includes],
55 install: enable_installed_tests,
56 install_dir: installed_tests_dir,
57 )
58 test(
59 'unit/xdp-method-info',
60 test_method_info,
61 suite: ['unit'],
62 env: env_tests,
63 is_parallel: true,
64 protocol: test_protocol,
65 )
66
67 run_test = find_program('run-test.sh')
68
69 pytest_args = ['--verbose', '--log-level=DEBUG']
70
71 pytest_env = environment()
72 pytest_env.set('BUILDDIR', meson.project_build_root())
73 pytest_env.set('UNDER_MESON', '1')
74
75 # pytest xdist is nice because it significantly speeds up our
76 # test process, but it's not required
77 if pymod.find_installation('python3', modules: ['xdist'], required: false).found()
78 # using auto can easily start too many tests which will block each other
79 # a value of around 5 seems to work well
80 pytest_args += ['-n', '5']
81 endif
82
83 pytest_files = [
84 'test_account.py',
85 'test_background.py',
86 'test_camera.py',
87 'test_clipboard.py',
88 'test_documents.py',
89 'test_document_fuse.py',
90 'test_dynamiclauncher.py',
91 'test_email.py',
92 'test_filechooser.py',
93 'test_globalshortcuts.py',
94 'test_inhibit.py',
95 'test_inputcapture.py',
96 'test_location.py',
97 'test_notification.py',
98 'test_openuri.py',
99 'test_permission_store.py',
100 'test_print.py',
101 'test_registry.py',
102 'test_remotedesktop.py',
103 'test_settings.py',
104 'test_screenshot.py',
105 'test_trash.py',
106 'test_usb.py',
107 'test_wallpaper.py',
108 ]
109
110 template_files = [
111 'templates/access.py',
112 'templates/account.py',
113 'templates/appchooser.py',
114 'templates/background.py',
115 'templates/clipboard.py',
116 'templates/dynamiclauncher.py',
117 'templates/email.py',
118 'templates/filechooser.py',
119 'templates/geoclue2.py',
120 'templates/globalshortcuts.py',
121 'templates/inhibit.py',
122 'templates/inputcapture.py',
123 'templates/lockdown.py',
124 'templates/notification.py',
125 'templates/print.py',
126 'templates/remotedesktop.py',
127 'templates/screenshot.py',
128 'templates/settings.py',
129 'templates/usb.py',
130 'templates/wallpaper.py',
131 'templates/xdp_utils.py',
132 ]
133
134 foreach pytest_file : pytest_files
135 testname = pytest_file.replace('.py', '').replace('test_', '')
136 test(
137 'integration/@0@'.format(testname),
138 run_test,
139 args: [meson.current_source_dir() / pytest_file] + pytest_args,
140 depends: [
141 xdg_desktop_portal,
142 xdp_validate_icon,
143 xdp_validate_sound,
144 xdg_permission_store,
145 xdg_document_portal,
146 ],
147 env: pytest_env,
148 suite: ['integration'],
149 timeout: 120,
150 )
151 endforeach
152
153 if enable_installed_tests
154 install_data(
155 pytest_files,
156 '__init__.py',
157 'conftest.py',
158 'xdp_utils.py',
159 'xdp_doc_utils.py',
160 'asan.suppression',
161 'valgrind.suppression',
162 install_dir: installed_tests_dir / 'tests',
163 )
164 install_data(
165 template_files,
166 install_dir: installed_tests_dir / 'tests' / 'templates',
167 )
168
169 installed_env = {
170 'XDG_DESKTOP_PORTAL_PATH': libexecdir / 'xdg-desktop-portal',
171 'XDG_PERMISSION_STORE_PATH': libexecdir / 'xdg-permission-store',
172 'XDG_DOCUMENT_PORTAL_PATH': libexecdir / 'xdg-document-portal',
173 'XDP_VALIDATE_AUTO': '1',
174 }
175 env = ''
176 foreach key, value : installed_env
177 env += f'@key@=@value@ '
178 endforeach
179
180 foreach pytest_file : pytest_files
181 testname = pytest_file.replace('.py', '').replace('test_', '')
182
183 exec = [pytest.full_path(), installed_tests_dir / 'tests' / pytest_file]
184 exec += pytest_args
185 exec += ['-p', 'no:cacheprovider']
186 exec = ' '.join(exec)
187
188 data = configuration_data()
189 data.set('exec', exec)
190 data.set('env', env)
191 data.set('libdir', libdir)
192
193 configure_file(
194 input: 'template.test.in',
195 output: 'integration-@[email protected]'.format(testname),
196 configuration: data,
197 install: true,
198 install_dir: installed_tests_data_dir,
199 )
200 endforeach
201 endif