File: meson.build

package info (click to toggle)
phosh 0.53.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 9,936 kB
  • sloc: ansic: 83,383; xml: 3,981; python: 717; sh: 449; makefile: 34; lisp: 22; javascript: 6
file content (402 lines) | stat: -rw-r--r-- 10,073 bytes parent folder | download | duplicates (2)
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
run_phoc_tests = false

subdir('stubs')

if not get_option('tests')
  subdir_done()
endif

subdir('services')
subdir('system')
subdir('user')
subdir('integration')

screenshot_langs = ['ar_AE.UTF-8', 'de_DE.UTF-8', 'ja_JP.UTF-8', 'uk_UA.UTF-8']

phoc = find_program('phoc', required: get_option('phoc_tests'), disabler: true)
run_phoc_tests = phoc.found() and not get_option('phoc_tests').disabled()

test_env_common = environment()
test_env_common.set('G_TEST_SRCDIR', meson.current_source_dir())
test_env_common.set('G_TEST_BUILDDIR', meson.current_build_dir())
test_env_common.set('G_DEBUG', 'gc-friendly,fatal-warnings')
test_env_common.set('GSETTINGS_BACKEND', 'memory')
test_env_common.set(
  'GSETTINGS_SCHEMA_DIR',
  '@0@/data:@1@'.format(meson.project_build_root(), plugin_schema_path),
)
# Make sure we use Phosh's gsetting prefs
test_env_common.set('XDG_CURRENT_DESKTOP', 'Phosh:GNOME')
test_env_common.set('PYTHONDONTWRITEBYTECODE', 'yes')
test_env_common.set('MALLOC_CHECK_', '2')
test_env_common.set('NO_AT_BRIDGE', '1')
# For GTK4 apps running in the tests:
test_env_common.set('GTK_A11Y', 'none')
# Make sure gvfs doesn't linger around
test_env_common.set('GIO_USE_VFS', 'local')

# For -Db_sanitize=address
test_env_common.set(
  'LSAN_OPTIONS',
  'suppressions=@0@/data/leak-suppress.txt'.format(meson.project_source_root()),
)
# as our libraries lack frame pointers since otherwise back traces are incomplete
test_env_common.set('ASAN_OPTIONS', 'fast_unwind_on_malloc=0')
# Useful when running locally and glib hits an assertion:
#test_env_common.set('ASAN_OPTIONS', 'fast_unwind_on_malloc=0:disable_coredump=0:unmap_shadow_on_exit=1:abort_on_error=1')

# xdg setup for the app-grid:
test_env_unit = test_env_common
test_env_unit.set(
  'XDG_CONFIG_HOME',
  '@0@/user/config/'.format(meson.current_source_dir()),
)
test_env_unit.set(
  'XDG_CONFIG_DIRS',
  '@0@/system/config/'.format(meson.current_source_dir()),
)
test_env_unit.set(
  'XDG_DATA_HOME',
  '@0@/user/share/'.format(meson.current_source_dir()),
)
test_env_unit.set('XDG_DATA_DIRS', '/usr/local/share/', '/usr/share/')
# Ideally we would just set it so that we have a known set of .desktop etc
# but then we can't find the system gschemas
test_env_unit.prepend(
  'XDG_DATA_DIRS',
  '@0@/system/share/'.format(meson.current_source_dir()),
)


test_resources = gnome.compile_resources(
  'phosh-test-resources',
  'phosh-test.gresources.xml',
  extra_args: '--manual-register',
  c_name: 'phosh_test',
)

test_cflags = [
  '-DTEST_BUILD_DIR="@0@"'.format(meson.project_build_root()),
  '-DTEST_DATA_DIR="@0@/data"'.format(meson.current_source_dir()),
  '-DTEST_OUTPUT_DIR="@0@"'.format(meson.current_build_dir()),
  '-DTEST_PHOC_INI="@0@/data/phoc.ini"'.format(meson.project_source_root()),
  '-DTEST_TOOLS="@0@/tools"'.format(meson.project_build_root()),
]

test_link_args = ['-fPIC']

testlib_sources = [
  'testlib.c',
  'testlib-head-stub.c',
  'testlib-compositor.c',
  'testlib-full-shell.c',
  'testlib-calls-mock.c',
  'testlib-mpris-mock.c',
  'testlib-emergency-calls.c',
  'testlib-wait-for-shell-state.c',
] + test_resources

testlib = static_library(
  'phoshtest',
  testlib_sources,
  dependencies: [phosh_deps, phosh_tool_dep],
  c_args: test_cflags,
)
testlib_dep = declare_dependency(
  include_directories: include_directories('.'),
  dependencies: phosh_tool_dep,
  link_with: testlib,
)

tests_unit = [
  'activity',
  'app-grid-button',
  'app-grid-folder-button',
  'app-list-model',
  'auto-brightness-bucket',
  'connectivity-info',
  'css',
  'fading-label',
  'favourite-model',
  'folder-info',
  'gamma-table',
  'head',
  'keypad',
  'media-player',
  'mount-notification',
  'notification',
  'notification-content',
  'notification-frame',
  'notification-list',
  'notification-source',
  'notify-feedback',
  'overview',
  'plugin-loader',
  'quick-setting',
  'quick-settings-box',
  'status-icon',
  'timestamp-label',
  'util',
  'wall-clock',
]

tests_searchd = ['search-result-meta', 'search-source', 'search-provider']

tests_phoc = [
  'app-auth-prompt',
  'background',
  'drag-surface',
  'end-session-dialog',
  'layer-surface',
  'lockshield',
  'notification-banner',
  'osd-window',
  'system-modal',
  'system-modal-dialog',
  'power-menu',
]

tests_manager = [
  ['calls-manager', true],
  ['gtk-mount-manager', true],
  ['idle-manager', true],
  ['lockscreen', true],
  ['monitor-manager', true],
  ['notify-manager', true],
  ['screenshot-manager', true],
]

# Unit tests
foreach test : tests_unit
  t = executable(
    'test-@0@'.format(test),
    ['test-@0@.c'.format(test)],
    c_args: test_cflags,
    pie: true,
    link_args: test_link_args,
    dependencies: [testlib_dep, test_stubs_dep],
  )
  test(test, t, env: test_env_unit, depends: compiled_schemas, suite: ['unit'])
endforeach

foreach test : tests_searchd
  t = executable(
    'test-@0@'.format(test),
    ['test-@0@.c'.format(test)],
    c_args: test_cflags,
    pie: true,
    link_args: test_link_args,
    dependencies: [testlib_dep, test_stubs_dep, phosh_search_dep],
  )
  test(
    test,
    t,
    env: test_env_unit,
    depends: mock_search_provider_exec,
    suite: ['unit'],
  )
endforeach

if run_phoc_tests
  test_env_phoc = test_env_common
  # Make sure this is valid when running the compositor
  test_env_phoc.set('XDG_RUNTIME_DIR', meson.current_build_dir())

  # Unit tests
  foreach test : tests_phoc
    t = executable(
      'test-@0@'.format(test),
      ['test-@0@.c'.format(test)],
      c_args: test_cflags,
      pie: true,
      link_args: test_link_args,
      dependencies: [testlib_dep, test_stubs_dep],
    )
    test(test, t, suite: ['unit', 'phoc'], env: test_env_phoc, is_parallel: true)
  endforeach

  # Integration tests using the full libphosh
  t = executable(
    'test-shell',
    'test-shell.c',
    c_args: test_cflags,
    pie: true,
    link_args: test_link_args,
    dependencies: [phosh_static_lib_dep, testlib_dep],
  )
  test('shell', t, env: test_env_phoc, suite: ['integration'], is_parallel: true)
  foreach item : tests_manager
    test = item.get(0)
    parallel = item.get(1)

    t = executable(
      'test-@0@'.format(test),
      ['test-@0@.c'.format(test), generated_dbus_sources],
      c_args: test_cflags,
      pie: true,
      link_args: test_link_args,
      dependencies: [phosh_static_lib_dep, testlib_dep],
    )
    test(
      test,
      t,
      env: test_env_phoc,
      suite: ['integration'],
      is_parallel: parallel,
    )
  endforeach

  # Tests for manual validation
  t = executable(
    'test-take-screenshots',
    ['test-take-screenshots.c', generated_dbus_sources],
    c_args: test_cflags,
    pie: true,
    link_args: test_link_args + phosh_export_sym_link_arg,
    dependencies: [phosh_static_lib_dep, testlib_dep],
  )
  foreach lang : screenshot_langs
    lang_env = test_env_phoc
    lang_env.set('LANGUAGE', lang)
    lang_env.set('LC_ALL', lang)
    lang_env.set('PHOSH_TEST_TYPE', lang)
    lang_env.set(
      'XDG_DATA_HOME',
      '@0@/user/share/'.format(meson.current_source_dir()),
    )
    test(
      'screenshots-@0@'.format(lang),
      t,
      env: lang_env,
      suite: ['screenshots'],
      timeout: 60,
    )
  endforeach

  what = 'high-contrast'
  hc_env = test_env_phoc
  hc_env.set('LANGUAGE', 'C')
  hc_env.set('PHOSH_TEST_TYPE', what)
  hc_env.set(
    'XDG_CONFIG_HOME',
    '@0@/user/config-@1@/'.format(meson.current_build_dir(), what),
  )
  hc_env.set(
    'XDG_DATA_HOME',
    '@0@/user/share/'.format(meson.current_source_dir()),
  )
  hc_env.set('GSETTINGS_BACKEND', 'keyfile')
  test(
    'screenshots-@0@'.format(what),
    t,
    env: hc_env,
    depends: copy_keyfile_hc,
    suite: ['screenshots'],
    timeout: 120,
  )

  what = 'landscape'
  landscape_env = test_env_phoc
  landscape_env.set('LANGUAGE', 'C')
  landscape_env.set('PHOSH_TEST_TYPE', what)
  landscape_env.set(
    'PHOSH_TEST_PHOC_INI',
    '@0@/data/phoc-landscape.ini'.format(meson.current_source_dir()),
  )
  landscape_env.set(
    'XDG_DATA_HOME',
    '@0@/user/share/'.format(meson.current_source_dir()),
  )
  test(
    'screenshots-@0@'.format(what),
    t,
    env: landscape_env,
    suite: ['screenshots'],
    timeout: 60,
  )

  what = 'notch'
  notch_env = test_env_phoc
  notch_env.set('LANGUAGE', 'C')
  notch_env.set('PHOC_DEBUG', 'cutouts')
  notch_env.set('PHOSH_DEBUG', 'fake-builtin')
  notch_env.set('PHOSH_TEST_TYPE', what)
  notch_env.set(
    'PHOSH_TEST_PHOC_INI',
    '@0@/data/phoc-notch.ini'.format(meson.current_source_dir()),
  )
  notch_env.set('GMOBILE_DT_COMPATIBLES', 'oneplus,fajita')
  notch_env.set(
    'XDG_DATA_HOME',
    '@0@/user/share/'.format(meson.current_source_dir()),
  )
  test(
    'screenshots-@0@'.format(what),
    t,
    env: notch_env,
    suite: ['screenshots'],
    timeout: 120,
  )
endif

foreach opt : ['--help', '--version']
  test(
    'phosh @0@'.format(opt),
    phosh,
    args: opt,
    env: test_env_unit,
    suite: ['unit'],
    timeout: 15,
    is_parallel: true,
  )
endforeach

flake8 = find_program('flake8', required: false)
black = find_program('black', required: false)
ruff = find_program('ruff', required: false)

pyfiles = files(
  'integration/__init__.py',
  'integration/test_dbus.py',
  'integration/test_output.py',
  'mock-mm-nm.py',
)

foreach pyfile : pyfiles
  if flake8.found()
    test(
      'flake8-@0@'.format(fs.name(pyfile)),
      flake8,
      args: ['--ignore', 'E501', pyfile],
      env: test_env_unit,
      suite: ['lint'],
      timeout: 15,
      is_parallel: true,
    )
  endif

  if black.found()
    test(
      'black-@0@'.format(fs.name(pyfile)),
      black,
      args: ['--check', '--diff', pyfile],
      env: test_env_unit,
      suite: ['lint'],
      timeout: 15,
      is_parallel: true,
    )
  endif

  if ruff.found()
    test(
      'ruff-@0@'.format(fs.name(pyfile)),
      ruff,
      args: ['check', '--no-cache', pyfile],
      env: test_env_unit,
      suite: ['lint'],
      timeout: 15,
      is_parallel: true,
    )
  endif

endforeach