From 4c98a9cd6b16a557c7c6ae24d938ff1ed88bc1ff Mon Sep 17 00:00:00 2001 From: Niels De Graef Date: Sun, 15 Jan 2023 23:30:17 +0100 Subject: [PATCH] meson: Make default test setup with D-Bus This makes sure that our tests run within their own D-Bus session (which is a requirement most of the time) As a result, we can get rid of a few workarounds in our CI to setup such a session. --- .gitlab-ci.yml | 14 -------------- meson.build | 6 ++++++ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ee7f341..660ad80 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,12 +9,9 @@ variables: fedora:Werror: stage: build - before_script: - - dbus-uuidgen --ensure script: - meson _build -Dwerror=true -Dc_args=-Wno-error=deprecated-declarations -Dgtk_doc=false - meson compile -C _build - - eval `dbus-launch --sh-syntax` - meson test -C _build artifacts: when: on_failure @@ -23,12 +20,9 @@ fedora:Werror: fedora:asan: stage: build - before_script: - - dbus-uuidgen --ensure script: - meson _build -Db_sanitize=address -Dgtk_doc=false -Dintrospection=false - meson compile -C _build - - eval `dbus-launch --sh-syntax` - meson test -C _build allow_failure: true artifacts: @@ -38,12 +32,9 @@ fedora:asan: fedora:ubsan: stage: build - before_script: - - dbus-uuidgen --ensure script: - meson _build -Db_sanitize=undefined -Dgtk_doc=false - meson compile -C _build - - eval `dbus-launch --sh-syntax` - meson test -C _build artifacts: when: on_failure @@ -52,8 +43,6 @@ fedora:ubsan: fedora-static-analyzers/test: stage: build - before_script: - - dbus-uuidgen --ensure script: - meson _build -Dgtk_doc=false - meson compile -C _build --ninja-args scan-build @@ -65,12 +54,9 @@ fedora-static-analyzers/test: fedora:coverage: stage: build - before_script: - - dbus-uuidgen --ensure script: - meson _build -Db_coverage=true -Dtpm2=true -Dgtk_doc=false - meson compile -C _build - - eval `dbus-launch --sh-syntax` - export XDG_CONFIG_HOME=$HOME/.config - /usr/share/swtpm/swtpm-create-user-config-files --root - mkdir -p ${XDG_CONFIG_HOME}/mytpm1 diff --git a/meson.build b/meson.build index 81b4d20..97bea7d 100644 --- a/meson.build +++ b/meson.build @@ -75,6 +75,12 @@ configure_file(output: 'config.h', configuration: conf) test_env = environment() test_env.set('abs_top_builddir', meson.build_root()) +# Most tests require a D-Bus session +add_test_setup('headless', + exe_wrapper: find_program('dbus-run-session'), + is_default: true, +) + # Subfolders subdir('po') subdir('egg')