[glib: 1/2] tests: Use g_test_skip() to skip a test on Windows




commit 0c27ac82870565ec1591765930cfffd36b93edd4
Author: Philip Withnall <philip tecnocode co uk>
Date:   Thu Feb 10 13:40:28 2022 +0000

    tests: Use g_test_skip() to skip a test on Windows

 glib/tests/fileutils.c | 10 +++++-----
 glib/tests/gdatetime.c |  8 ++++----
 2 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/glib/tests/fileutils.c b/glib/tests/fileutils.c
index 7eda5391e..7083cf204 100644
--- a/glib/tests/fileutils.c
+++ b/glib/tests/fileutils.c
@@ -1452,11 +1452,11 @@ test_set_contents_full_read_only_file (void)
   g_free (file_name);
 }
 
-#ifndef G_OS_WIN32
-/* windows mostly ignores read-only flagged directoy, chmod doesn't work */
 static void
 test_set_contents_full_read_only_directory (void)
 {
+#ifndef G_OS_WIN32
+/* windows mostly ignores read-only flagged directories, chmod doesn't work */
   GFileSetContentsFlags flags_mask =
       G_FILE_SET_CONTENTS_ONLY_EXISTING |
       G_FILE_SET_CONTENTS_DURABLE |
@@ -1510,8 +1510,10 @@ test_set_contents_full_read_only_directory (void)
       g_free (file_name);
       g_free (dir_name);
     }
-}
+#else
+  g_test_skip ("Windows doesn’t support read-only directories in the same way as Unix");
 #endif
+}
 
 static void
 test_read_link (void)
@@ -2161,9 +2163,7 @@ main (int   argc,
   g_test_add_func ("/fileutils/set-contents", test_set_contents);
   g_test_add_func ("/fileutils/set-contents-full", test_set_contents_full);
   g_test_add_func ("/fileutils/set-contents-full/read-only-file", test_set_contents_full_read_only_file);
-#ifndef G_OS_WIN32
   g_test_add_func ("/fileutils/set-contents-full/read-only-directory", 
test_set_contents_full_read_only_directory);
-#endif
   g_test_add_func ("/fileutils/read-link", test_read_link);
   g_test_add_func ("/fileutils/stdio-wrappers", test_stdio_wrappers);
   g_test_add_func ("/fileutils/fopen-modes", test_fopen_modes);
diff --git a/glib/tests/gdatetime.c b/glib/tests/gdatetime.c
index a4dbd0544..d2d1ec1a6 100644
--- a/glib/tests/gdatetime.c
+++ b/glib/tests/gdatetime.c
@@ -2970,10 +2970,10 @@ test_new_offset (void)
     }
 }
 
-#ifndef G_OS_WIN32
 static void
 test_time_zone_parse_rfc8536 (void)
 {
+#ifndef G_OS_WIN32
   const gchar *test_files[] =
     {
       /* Generated with `zic -b slim`; see
@@ -2999,8 +2999,10 @@ test_time_zone_parse_rfc8536 (void)
       g_time_zone_unref (tz);
       g_free (path);
     }
-}
+#else
+  g_test_skip ("RFC 8536 format time zone files are not available on Windows");
 #endif
+}
 
 /* Check GTimeZone instances are cached. */
 static void
@@ -3152,9 +3154,7 @@ main (gint   argc,
   g_test_add_func ("/GTimeZone/floating-point", test_GDateTime_floating_point);
   g_test_add_func ("/GTimeZone/identifier", test_identifier);
   g_test_add_func ("/GTimeZone/new-offset", test_new_offset);
-#ifndef G_OS_WIN32
   g_test_add_func ("/GTimeZone/parse-rfc8536", test_time_zone_parse_rfc8536);
-#endif
   g_test_add_func ("/GTimeZone/caching", test_time_zone_caching);
 
   return g_test_run ();


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