tests: Skip appinfo/associations test if update-*-database not installed

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 <philip@tecnocode.co.uk>

Helps: #3148
This commit is contained in:
Philip Withnall 2023-10-22 22:49:48 +01:00
parent 8e959e32b1
commit 8629024243
2 changed files with 15 additions and 2 deletions

View File

@ -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,

View File

@ -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,