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 env_tests.set('LSAN_OPTIONS', 'suppressions=' + meson.current_source_dir() / 'asan.suppression')
7
8 if glib_dep.version().version_compare('>= 2.68')
9 test_protocol = 'tap'
10 else
11 test_protocol = 'exitcode'
12 endif
13
14 subdir('dbs')
15 test_permission_db = executable(
16 'test-permission-db',
17 ['test-permission-db.c'] + db_sources,
18 dependencies: [common_deps],
19 include_directories: [common_includes],
20 install: enable_installed_tests,
21 install_dir: installed_tests_dir,
22 )
23 test(
24 'unit/permission-db',
25 test_permission_db,
26 suite: ['unit'],
27 env: env_tests,
28 is_parallel: false,
29 protocol: test_protocol,
30 )
31
32 test_xdp_utils = executable(
33 'test-xdp-utils',
34 'test-xdp-utils.c',
35 xdp_utils_sources,
36 dependencies: [common_deps, xdp_utils_deps],
37 include_directories: [common_includes, xdp_utils_includes],
38 install: enable_installed_tests,
39 install_dir: installed_tests_dir,
40 )
41 test(
42 'unit/xdp-utils',
43 test_xdp_utils,
44 suite: ['unit'],
45 env: env_tests,
46 is_parallel: false,
47 protocol: test_protocol,
48 )
49
50 test_method_info = executable(
51 'test-xdp-method-info',
52 'test-xdp-method-info.c',
53 xdp_method_info_sources,
54 dependencies: [common_deps],
55 include_directories: [common_includes, xdp_utils_includes],
56 install: enable_installed_tests,
57 install_dir: installed_tests_dir,
58 )
59 test(
60 'unit/xdp-method-info',
61 test_method_info,
62 suite: ['unit'],
63 env: env_tests,
64 is_parallel: true,
65 protocol: test_protocol,
66 )
67
68 run_test = find_program('run-test.sh')
69
70 pytest_args = ['--verbose', '--log-level=DEBUG']
71
72 pytest_env = environment()
73 pytest_env.set('BUILDDIR', meson.project_build_root())
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/__init__.py',
123 'templates/inputcapture.py',
124 'templates/lockdown.py',
125 'templates/notification.py',
126 'templates/print.py',
127 'templates/remotedesktop.py',
128 'templates/screenshot.py',
129 'templates/settings.py',
130 'templates/usb.py',
131 'templates/wallpaper.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 env: pytest_env,
141 suite: ['integration'],
142 timeout: 120,
143 )
144 endforeach
145
146 if enable_installed_tests
147 install_data(
148 pytest_files,
149 '__init__.py',
150 'conftest.py',
151 'asan.suppression',
152 install_dir: installed_tests_dir / 'tests',
153 )
154 install_data(
155 template_files,
156 install_dir: installed_tests_dir / 'tests' / 'templates',
157 )
158
159 installed_env = {
160 'XDG_DESKTOP_PORTAL_PATH': libexecdir / 'xdg-desktop-portal',
161 'XDG_PERMISSION_STORE_PATH': libexecdir / 'xdg-permission-store',
162 'XDG_DOCUMENT_PORTAL_PATH': libexecdir / 'xdg-document-portal',
163 'XDP_VALIDATE_AUTO': '1',
164 }
165 env = ''
166 foreach key, value : installed_env
167 env += f'@key@=@value@ '
168 endforeach
169
170 foreach pytest_file : pytest_files
171 testname = pytest_file.replace('.py', '').replace('test_', '')
172
173 exec = [pytest.full_path(), installed_tests_dir / 'tests' / pytest_file]
174 exec += pytest_args
175 exec += ['-p', 'no:cacheprovider']
176 exec = ' '.join(exec)
177
178 data = configuration_data()
179 data.set('exec', exec)
180 data.set('env', env)
181 data.set('libdir', libdir)
182
183 configure_file(
184 input: 'template.test.in',
185 output: 'integration-@[email protected]'.format(testname),
186 configuration: data,
187 install: true,
188 install_dir: installed_tests_data_dir,
189 )
190 endforeach
191 endif