From a98bd895d58f878602b622b98f7f27dd270262ac Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 24 Jun 2022 12:04:31 +0100 Subject: [PATCH 1/3] tests: Fix a path comparison in the file tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On macOS the comparison was failing as one of the paths had a trailing slash while the other didn’t. Signed-off-by: Philip Withnall --- gio/tests/file.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gio/tests/file.c b/gio/tests/file.c index 39444158f..04805931b 100644 --- a/gio/tests/file.c +++ b/gio/tests/file.c @@ -1988,7 +1988,7 @@ on_new_tmp_done (GObject *object, GError *error = NULL; GMainLoop *loop = user_data; gchar *basename; - gchar *parent_path; + GFile *tmpdir = NULL; g_assert_null (object); @@ -2009,9 +2009,9 @@ on_new_tmp_done (GObject *object, g_assert_no_error (error); parent = g_file_get_parent (file); - parent_path = g_file_get_path (parent); + tmpdir = g_file_new_for_path (g_get_tmp_dir ()); - g_assert_cmpstr (g_get_tmp_dir (), ==, parent_path); + g_assert_true (g_file_equal (tmpdir, parent)); g_main_loop_quit (loop); @@ -2020,7 +2020,7 @@ on_new_tmp_done (GObject *object, g_object_unref (iostream); g_object_unref (info); g_free (basename); - g_free (parent_path); + g_object_unref (tmpdir); } static void @@ -2087,7 +2087,7 @@ on_new_tmp_dir_done (GObject *object, GError *error = NULL; GMainLoop *loop = user_data; gchar *basename; - gchar *parent_path; + GFile *tmpdir = NULL; g_assert_null (object); @@ -2106,9 +2106,9 @@ on_new_tmp_dir_done (GObject *object, g_assert_cmpuint (g_file_info_get_file_type (info), ==, G_FILE_TYPE_DIRECTORY); parent = g_file_get_parent (file); - parent_path = g_file_get_path (parent); + tmpdir = g_file_new_for_path (g_get_tmp_dir ()); - g_assert_cmpstr (g_get_tmp_dir (), ==, parent_path); + g_assert_true (g_file_equal (tmpdir, parent)); g_main_loop_quit (loop); @@ -2116,7 +2116,7 @@ on_new_tmp_dir_done (GObject *object, g_object_unref (parent); g_object_unref (info); g_free (basename); - g_free (parent_path); + g_object_unref (tmpdir); } static void From dbdc9ca9959c01d2fced578ecc1f18b3cc86eb2d Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 24 Jun 2022 12:17:37 +0100 Subject: [PATCH 2/3] gosxappinfo: Correctly return an error from create_from_commandline() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Creating a `GAppInfo` from a commandline isn’t currently supported on macOS, but the implementation was incorrectly returning `NULL` without setting the `GError`. This was being caught by the new tests in `gio/tests/file.c`. Signed-off-by: Philip Withnall --- gio/gosxappinfo.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gio/gosxappinfo.m b/gio/gosxappinfo.m index 03c373778..a0bf72226 100644 --- a/gio/gosxappinfo.m +++ b/gio/gosxappinfo.m @@ -587,6 +587,9 @@ g_app_info_create_from_commandline (const char *commandline, GAppInfoCreateFlags flags, GError **error) { + g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, + "Creating an app info from a command line not currently supported"); + return NULL; } From 059a5fd4dabfe72939e669ee7c84dd938e3bcd6a Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 24 Jun 2022 12:43:18 +0100 Subject: [PATCH 3/3] tests: Skip various default handler tests on macOS They are not currently supported by `gosxappinfo.m`. Signed-off-by: Philip Withnall --- gio/tests/file.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gio/tests/file.c b/gio/tests/file.c index 04805931b..9a15f9726 100644 --- a/gio/tests/file.c +++ b/gio/tests/file.c @@ -3493,8 +3493,8 @@ test_query_default_handler_uri (void) GFile *file; GFile *invalid_file; -#ifdef G_OS_WIN32 - g_test_skip ("Default URI handlers are not currently supported on Windows"); +#if defined(G_OS_WIN32) || defined(__APPLE__) + g_test_skip ("Default URI handlers are not currently supported on Windows or macOS"); return; #endif @@ -3536,8 +3536,8 @@ test_query_default_handler_file (void) const char buffer[] = "Text file!\n"; const guint8 binary_buffer[] = "\xde\xad\xbe\xff"; -#ifdef G_OS_WIN32 - g_test_skip ("Default URI handlers are not currently supported on Windows"); +#if defined(G_OS_WIN32) || defined(__APPLE__) + g_test_skip ("Default URI handlers are not currently supported on Windows or macOS"); return; #endif @@ -3626,8 +3626,8 @@ test_query_default_handler_file_async (void) const guint8 binary_buffer[] = "\xde\xad\xbe\xff"; GError *error = NULL; -#ifdef G_OS_WIN32 - g_test_skip ("Default URI handlers are not currently supported on Windows"); +#if defined(G_OS_WIN32) || defined(__APPLE__) + g_test_skip ("Default URI handlers are not currently supported on Windows or macOS"); return; #endif @@ -3716,8 +3716,8 @@ test_query_default_handler_uri_async (void) GFile *file; GFile *invalid_file; -#ifdef G_OS_WIN32 - g_test_skip ("Default URI handlers are not currently supported on Windows"); +#if defined(G_OS_WIN32) || defined(__APPLE__) + g_test_skip ("Default URI handlers are not currently supported on Windows or macOS"); return; #endif