From 862902424302ebd23b4148b4e0b959b36d9cfcf0 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Sun, 22 Oct 2023 22:49:48 +0100 Subject: [PATCH] tests: Skip appinfo/associations test if update-*-database not installed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If `update-desktop-database` or `update-mime-database` are not installed, there are a few `GAppInfo` methods for modifying file associations which will print a `g_warning()` when called. Something like: ``` GLib-GIO-FATAL-WARNING: Failed to execute child process ‘update-desktop-database’ (No such file or directory) ``` (Example: https://gitlab.gnome.org/zamaudio/glib/-/jobs/3190053) This will cause the appinfo/associations test to fail, as warnings are fatal. If that’s going to happen, skip the test. We can’t hard-depend on these tools as they are external to GLib and only needed for a few operations. Instead we have a soft runtime dependency on them; that should be reflected in the tests. Signed-off-by: Philip Withnall Helps: #3148 --- gio/tests/appinfo.c | 15 +++++++++++++++ gio/tests/meson.build | 2 -- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gio/tests/appinfo.c b/gio/tests/appinfo.c index 625b828f3..6a2ae697b 100644 --- a/gio/tests/appinfo.c +++ b/gio/tests/appinfo.c @@ -384,6 +384,21 @@ test_associations (void) gboolean result; GList *list; gchar *cmdline; + gchar *update_desktop_database = NULL, *update_mime_database = NULL; + + update_desktop_database = g_find_program_in_path ("update-desktop-database"); + update_mime_database = g_find_program_in_path ("update-mime-database"); + + if (update_desktop_database == NULL || update_mime_database == NULL) + { + g_test_skip ("update-desktop-database and update-mime-database are needed to change file associations"); + g_free (update_desktop_database); + g_free (update_mime_database); + return; + } + + g_free (update_desktop_database); + g_free (update_mime_database); cmdline = g_strconcat (g_test_get_dir (G_TEST_BUILT), "/appinfo-test --option", NULL); appinfo = g_app_info_create_from_commandline (cmdline, diff --git a/gio/tests/meson.build b/gio/tests/meson.build index c46421127..aaf341691 100644 --- a/gio/tests/meson.build +++ b/gio/tests/meson.build @@ -330,8 +330,6 @@ if host_machine.system() != 'windows' 'appinfo' : { 'install' : false, 'extra_programs' : ['appinfo-test'], - # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3148 - 'can_fail' : host_system == 'gnu', }, 'desktop-app-info' : { 'install' : false,