Merge branch 'bootstrap-tests' into 'main'

tests: skip tests that will fail due to missing dependencies

Closes #3317

See merge request GNOME/glib!3997
This commit is contained in:
Philip Withnall 2024-06-14 15:56:38 +00:00
commit 15202c970a
4 changed files with 143 additions and 18 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

@ -13,6 +13,20 @@
__s1, " == ", __s2); \
} while (0)
static gboolean
skip_missing_shared_mime_info (void)
{
gchar *path = g_find_program_in_path ("update-mime-database");
if (path == NULL)
{
g_test_skip ("shared-mime-info is required to run this test");
return TRUE;
}
g_free (path);
return FALSE;
}
static void
test_guess (void)
{
@ -26,6 +40,9 @@ test_guess (void)
"Name=appinfo-test\n"
"Exec=./appinfo-test --option\n";
if (skip_missing_shared_mime_info ())
return;
#ifdef G_OS_WIN32
existing_directory = (gchar *) g_getenv ("SYSTEMROOT");
@ -150,6 +167,9 @@ test_subtype (void)
gchar *plain;
gchar *xml;
if (skip_missing_shared_mime_info ())
return;
plain = g_content_type_from_mime_type ("text/plain");
xml = g_content_type_from_mime_type ("application/xml");
@ -175,6 +195,9 @@ test_list (void)
gchar *plain;
gchar *xml;
if (skip_missing_shared_mime_info ())
return;
#ifdef __APPLE__
g_test_skip ("The OSX backend does not implement g_content_types_get_registered()");
return;
@ -202,6 +225,9 @@ test_executable (void)
{
gchar *type;
if (skip_missing_shared_mime_info ())
return;
#ifdef G_OS_WIN32
type = g_content_type_from_mime_type ("application/vnd.microsoft.portable-executable");
/* FIXME: the MIME is not in the default `MIME\Database\Content Type` registry.
@ -228,6 +254,9 @@ test_description (void)
gchar *type;
gchar *desc;
if (skip_missing_shared_mime_info ())
return;
type = g_content_type_from_mime_type ("text/plain");
desc = g_content_type_get_description (type);
g_assert_nonnull (desc);
@ -242,6 +271,9 @@ test_icon (void)
gchar *type;
GIcon *icon;
if (skip_missing_shared_mime_info ())
return;
type = g_content_type_from_mime_type ("text/plain");
icon = g_content_type_get_icon (type);
g_assert_true (G_IS_ICON (icon));
@ -290,6 +322,9 @@ test_symbolic_icon (void)
gchar *type;
GIcon *icon;
if (skip_missing_shared_mime_info ())
return;
type = g_content_type_from_mime_type ("text/plain");
icon = g_content_type_get_symbolic_icon (type);
g_assert_true (G_IS_ICON (icon));
@ -344,6 +379,9 @@ test_tree (void)
gchar **types;
gsize i;
if (skip_missing_shared_mime_info ())
return;
#if defined(__APPLE__) || defined(G_OS_WIN32)
g_test_skip ("The OSX & Windows backends do not implement g_content_type_guess_for_tree()");
return;
@ -437,8 +475,13 @@ test_guess_svg_from_data (void)
</svg>\n";
gboolean uncertain = TRUE;
gchar *res = g_content_type_guess (NULL, (guchar *)svgfilecontent,
sizeof (svgfilecontent) - 1, &uncertain);
gchar *res;
if (skip_missing_shared_mime_info ())
return;
res = g_content_type_guess (NULL, (guchar *)svgfilecontent,
sizeof (svgfilecontent) - 1, &uncertain);
#ifdef __APPLE__
g_assert_cmpstr (res, ==, "public.svg-image");
#elif defined(G_OS_WIN32)

View File

@ -125,6 +125,20 @@ create_app_info (const char *name)
return info;
}
static gboolean
skip_missing_update_desktop_database (void)
{
gchar *path = g_find_program_in_path ("update-desktop-database");
if (path == NULL)
{
g_test_skip ("update-desktop-database is required to run this test");
return TRUE;
}
g_free (path);
return FALSE;
}
static void
test_delete (void)
{
@ -134,6 +148,9 @@ test_delete (void)
char *filename;
gboolean res;
if (skip_missing_update_desktop_database ())
return;
info = create_app_info ("Blah");
id = g_app_info_get_id (info);
@ -177,6 +194,9 @@ test_default (void)
GList *list;
GError *error = NULL;
if (skip_missing_update_desktop_database ())
return;
info1 = create_app_info ("Blah1");
info2 = create_app_info ("Blah2");
info3 = create_app_info ("Blah3");
@ -316,6 +336,9 @@ test_default_async (void)
GList *list;
GError *error = NULL;
if (skip_missing_update_desktop_database ())
return;
data.loop = g_main_loop_new (NULL, TRUE);
info1 = create_app_info ("Blah1");
@ -418,6 +441,9 @@ test_fallback (void)
GError *error = NULL;
gint old_length;
if (skip_missing_update_desktop_database ())
return;
info1 = create_app_info ("Test1");
info2 = create_app_info ("Test2");
@ -492,6 +518,9 @@ test_last_used (void)
GAppInfo *info1, *info2, *default_app;
GError *error = NULL;
if (skip_missing_update_desktop_database ())
return;
info1 = create_app_info ("Test1");
info2 = create_app_info ("Test2");
@ -593,6 +622,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 +648,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);
@ -1206,6 +1251,9 @@ test_default_uri_handler (void)
gchar *file_path = NULL;
GAppInfo *info;
if (skip_missing_update_desktop_database ())
return;
info = create_app_info_toucher ("Touch Handled", "handled",
"x-scheme-handler/glib-touch",
&file_path);
@ -1282,6 +1330,9 @@ test_default_uri_handler_async (void)
gboolean called = FALSE;
gint64 start_time, touch_time;
if (skip_missing_update_desktop_database ())
return;
loop = g_main_loop_new (NULL, FALSE);
info = create_app_info_toucher ("Touch Handled", "handled-async",
"x-scheme-handler/glib-async-touch",
@ -1833,6 +1884,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);

View File

@ -3784,6 +3784,20 @@ create_command_line_app_info (const char *name,
return g_steal_pointer (&info);
}
static gboolean
skip_missing_update_desktop_database (void)
{
gchar *path = g_find_program_in_path ("update-desktop-database");
if (path == NULL)
{
g_test_skip ("update-desktop-database is required to run this test");
return TRUE;
}
g_free (path);
return FALSE;
}
static void
test_query_default_handler_uri (void)
{
@ -3793,10 +3807,8 @@ test_query_default_handler_uri (void)
GFile *file;
GFile *invalid_file;
#if defined(G_OS_WIN32) || defined(__APPLE__)
g_test_skip ("Default URI handlers are not currently supported on Windows or macOS");
return;
#endif
if (skip_missing_update_desktop_database ())
return;
info = create_command_line_app_info ("Gio File Handler", "true",
"x-scheme-handler/gio-file");
@ -3878,10 +3890,8 @@ test_query_default_handler_file (void)
const char buffer[] = "Text file!\n";
const guint8 binary_buffer[] = "\xde\xad\xbe\xff";
#if defined(G_OS_WIN32) || defined(__APPLE__)
g_test_skip ("Default URI handlers are not currently supported on Windows or macOS");
return;
#endif
if (skip_missing_update_desktop_database ())
return;
text_file = g_file_new_tmp ("query-default-handler-XXXXXX", &iostream, &error);
g_assert_no_error (error);
@ -3974,10 +3984,8 @@ test_query_default_handler_file_async (void)
const guint8 binary_buffer[] = "\xde\xad\xbe\xff";
GError *error = NULL;
#if defined(G_OS_WIN32) || defined(__APPLE__)
g_test_skip ("Default URI handlers are not currently supported on Windows or macOS");
return;
#endif
if (skip_missing_update_desktop_database ())
return;
data.loop = g_main_loop_new (NULL, FALSE);
@ -4064,10 +4072,8 @@ test_query_default_handler_uri_async (void)
GFile *file;
GFile *invalid_file;
#if defined(G_OS_WIN32) || defined(__APPLE__)
g_test_skip ("Default URI handlers are not currently supported on Windows or macOS");
return;
#endif
if (skip_missing_update_desktop_database ())
return;
info = create_command_line_app_info ("Gio File Handler", "true",
"x-scheme-handler/gio-file");