tests: skip tests that requires dbus-daemon when its missing

dbus may not be built yet during bootstrap, because it needs glib to
build.

Ref: https://gitlab.gnome.org/GNOME/glib/-/issues/3317
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
This commit is contained in:
Natanael Copa 2024-04-04 17:08:46 +02:00 committed by Philip Withnall
parent 6a262b0c03
commit 7322a925e2
2 changed files with 41 additions and 0 deletions

View File

@ -49,6 +49,19 @@ test_launch_for_app_info (GAppInfo *appinfo)
g_free (uri);
}
static gboolean
skip_missing_dbus_daemon (void)
{
gchar *path = g_find_program_in_path ("dbus-daemon");
if (path == NULL)
{
g_test_skip ("dbus-daemon is required to run this test");
return TRUE;
}
g_free (path);
return FALSE;
}
static void
test_launch (void)
{
@ -56,6 +69,9 @@ test_launch (void)
GAppInfo *appinfo;
const gchar *path;
if (skip_missing_dbus_daemon ())
return;
/* Set up a test session bus to keep D-Bus traffic off the real session bus. */
bus = g_test_dbus_new (G_TEST_DBUS_NONE);
g_test_dbus_up (bus);
@ -96,6 +112,9 @@ test_launch_no_app_id (void)
gchar *exec_line_variants[2];
gsize i;
if (skip_missing_dbus_daemon ())
return;
exec_line_variants[0] = g_strdup_printf (
"Exec=%s/appinfo-test --option %%U %%i --name %%c --filename %%k %%m %%%%",
g_test_get_dir (G_TEST_BUILT));
@ -356,6 +375,9 @@ test_launch_context_signals (void)
gboolean success;
gchar *cmdline;
if (skip_missing_dbus_daemon ())
return;
/* Set up a test session bus to keep D-Bus traffic off the real session bus. */
bus = g_test_dbus_new (G_TEST_DBUS_NONE);
g_test_dbus_up (bus);

View File

@ -593,6 +593,19 @@ wait_for_file (const gchar *want_this,
unlink (or_this);
}
static gboolean
skip_missing_dbus_daemon (void)
{
gchar *path = g_find_program_in_path ("dbus-daemon");
if (path == NULL)
{
g_test_skip ("dbus-daemon is required to run this test");
return TRUE;
}
g_free (path);
return FALSE;
}
static void
test_actions (void)
{
@ -606,6 +619,9 @@ test_actions (void)
gchar *tweak_path;
gchar *twiddle_path;
if (skip_missing_dbus_daemon ())
return;
/* Set up a test session bus to keep D-Bus traffic off the real session bus. */
bus = g_test_dbus_new (G_TEST_DBUS_NONE);
g_test_dbus_up (bus);
@ -1833,6 +1849,9 @@ test_launch_fail_dbus (void)
GAsyncResult *result = NULL;
GError *error = NULL;
if (skip_missing_dbus_daemon ())
return;
/* Set up a test session bus to ensure that launching the app happens using
* D-Bus rather than spawning. */
bus = g_test_dbus_new (G_TEST_DBUS_NONE);