[glib/wip/pwithnall/more-macos-fixes: 1/2] tests: Fix a path comparison in the file tests




commit a98bd895d58f878602b622b98f7f27dd270262ac
Author: Philip Withnall <pwithnall endlessos org>
Date:   Fri Jun 24 12:04:31 2022 +0100

    tests: Fix a path comparison in the file tests
    
    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 <pwithnall endlessos org>

 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 39444158f4..04805931b7 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]