qulogic/pidgin

Make broadwayd optional for unit testing

7 months ago, Gary Kramlich
d0faa9b1ac85
Parents 0f3a16f3ce7f
Children 8c296ed85b26
Make broadwayd optional for unit testing

gtk4-broadwayd isn't packaged for at least homebrew on macOS and maybe others,
so this only runs the broadway tests if broadway is found.

Testing Done:
Ran turtles normally and with the executable name tweaked so it couldn't be found.

Reviewed at https://reviews.imfreedom.org/r/2779/
--- a/pidgin/tests/meson.build Tue Nov 07 00:33:50 2023 -0600
+++ b/pidgin/tests/meson.build Tue Nov 07 01:04:39 2023 -0600
@@ -1,18 +1,21 @@
-PROGRAMS = [
+BROADWAY_TESTS = [
'text_buffer',
]
TEST_WRAPPER = find_program('./test-wrapper.py', required: true)
+BROADWAYD = find_program('gtk4-broadwayd', required: false)
testenv.set('XDG_CONFIG_HOME', meson.current_build_dir() / 'config')
-foreach program : PROGRAMS
- e = executable(f'test_@program@', f'test_@program@.c',
- c_args : [
- '-DTEST_DATA_DIR="@0@/data"'.format(meson.current_source_dir()),
- '-DTEST_CACHE_DIR="@0@/cache"'.format(meson.current_build_dir()),
- ],
- dependencies : [libpurple_dep, libpidgin_dep, glib, gtk],
- )
- test(program, TEST_WRAPPER, args : e, is_parallel : false, env: testenv)
-endforeach
+if BROADWAYD.found()
+ foreach program : BROADWAY_TESTS
+ e = executable(f'test_@program@', f'test_@program@.c',
+ c_args : ['-DTEST_DATA_DIR="@0@/data"'.format(meson.current_source_dir()),
+ '-DTEST_CACHE_DIR="@0@/cache"'.format(meson.current_build_dir())],
+ dependencies : [libpurple_dep, libpidgin_dep, glib, gtk])
+ test(program, TEST_WRAPPER,
+ args : [BROADWAYD.full_path(), e],
+ is_parallel : false,
+ env: testenv)
+ endforeach
+endif
--- a/pidgin/tests/test-wrapper.py Tue Nov 07 00:33:50 2023 -0600
+++ b/pidgin/tests/test-wrapper.py Tue Nov 07 01:04:39 2023 -0600
@@ -31,14 +31,19 @@
def main():
+ if len(sys.argv) < 2:
+ print('invalid arguments:')
+ print(f'usage: {sys.argv[0]} [path to gtk4-broadwayd] [tests]...')
+ sys.exit(1)
+
# start broadway
- broadwayd = subprocess.Popen(['gtk4-broadwayd'])
+ broadwayd = subprocess.Popen(sys.argv[1])
# run the unit test but set the GDK_BACKEND envvar to broadway
env = {**os.environ, 'GDK_BACKEND': 'broadway'}
try:
- proc = subprocess.run(args=sys.argv[1:], env=env)
+ proc = subprocess.run(args=sys.argv[2:], env=env)
finally:
# kill broadway
broadwayd.kill()