diff --git a/app/tests/meson.build b/app/tests/meson.build index 7b3cca1c9b..2900e061b4 100644 --- a/app/tests/meson.build +++ b/app/tests/meson.build @@ -58,6 +58,7 @@ foreach test_name : app_tests 'GIMP_TESTING_ABS_TOP_BUILDDIR='+ meson.build_root(), 'GIMP_TESTING_PLUGINDIRS=' + meson.build_root()/'plug-ins'/'common', 'GIMP_TESTING_PLUGINDIRS_BASENAME_IGNORES=mkgen.pl', + 'UI_TEST=yes', ], suite: 'app', ) diff --git a/build/meson/run_test_env.sh b/build/meson/run_test_env.sh new file mode 100644 index 0000000000..f71585a432 --- /dev/null +++ b/build/meson/run_test_env.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# +# Wrapper script to use for the Meson test setup. +# +# Define the "UI_TEST" for all tests that should run headless + +if [[ -n "${UI_TEST}" ]]; then + # Use Xvfb to simulate a graphical session; note that this needs + # a new enough version which has the -d option. + # + # Also use dbus-run-session to make sure parallel tests aren't failing + # as they simultaneously try to own the "org.gimp.GIMP.UI" D-Bus name + + xvfb-run -d --server-args="-screen 0 1280x1024x24" \ + dbus-run-session -- "$@" + +else + # Run the executable directly, + # i.e. no need to run Xvfb (which will have a timeout) + + "$@" +fi + diff --git a/meson.build b/meson.build index 304c79fe4f..956a13f363 100644 --- a/meson.build +++ b/meson.build @@ -1086,8 +1086,15 @@ if have_vector_icons endif endif -xvfb_run = find_program('xvfb-run', required: get_option('xvfb-run')) -conf.set('HAVE_XVFB_RUN', xvfb_run.found()) +# Running tests headless +xvfb_run = find_program('xvfb-run', required: get_option('headless-tests')) +dbus_run_session = find_program('dbus-run-session', required: get_option('headless-tests')) +if xvfb_run.found() and dbus_run_session.found() + add_test_setup('headless', + exe_wrapper: find_program('build' / 'meson' / 'run_test_env.sh'), + is_default: true, + ) +endif # Set bug report URL diff --git a/meson_options.txt b/meson_options.txt index 10255dc9ca..e59524d450 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -50,7 +50,7 @@ option('webp', type: 'feature', value: 'auto', description: 'Webp s option('wmf', type: 'feature', value: 'auto', description: 'Wmf support') option('xcursor', type: 'feature', value: 'auto', description: 'Xcursor support') option('xpm', type: 'feature', value: 'auto', description: 'XPM support') -option('xvfb-run', type: 'feature', value: 'auto', description: 'Use xvfb-run for UI-dependent automatic tests') +option('headless-tests', type: 'feature', value: 'auto', description: 'Use xvfb-run/dbus-run-session for UI-dependent automatic tests') option('gtk-doc', type: 'boolean', value: true, description: 'Build developer documentation') option('gtk-doc-app', type: 'boolean', value: false, description: 'Build developer documentation for app')