[libgweather/ebassi/gtk4: 7/56] tests: Skip tests if requested locale is not available




commit 237addd5c02f70c654b69f6697c502590594ae20
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Tue Oct 5 17:55:27 2021 +0100

    tests: Skip tests if requested locale is not available
    
    Make sure to mention it in the test log why the test was skipped.

 libgweather/test_libgweather.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/libgweather/test_libgweather.c b/libgweather/test_libgweather.c
index b10c1f16..1a710fec 100644
--- a/libgweather/test_libgweather.c
+++ b/libgweather/test_libgweather.c
@@ -678,6 +678,7 @@ test_location_names (void)
 {
     g_autoptr(GWeatherLocation) world = NULL;
     g_autoptr(GWeatherLocation) brussels = NULL;
+    char *old_locale;
 
     world = gweather_location_get_world ();
     g_assert_nonnull (world);
@@ -689,7 +690,11 @@ test_location_names (void)
     g_assert_cmpstr (gweather_location_get_english_name (brussels), ==, "Brussels");
     gweather_location_unref (brussels);
 
-    setlocale (LC_ALL, "fr_FR.UTF-8");
+    old_locale = setlocale (LC_ALL, "fr_FR.UTF-8");
+    if (old_locale == NULL) {
+        g_test_skip ("Locale fr_FR.UTF-8 is not available");
+        return;
+    }
 
     g_clear_pointer (&world, gweather_location_unref);
     g_clear_pointer (&brussels, gweather_location_unref);
@@ -705,7 +710,7 @@ test_location_names (void)
     g_assert_cmpstr (gweather_location_get_english_name (brussels), ==, "Brussels");
     gweather_location_unref (brussels);
 
-    setlocale (LC_ALL, "");
+    setlocale (LC_ALL, old_locale);
     g_clear_pointer (&world, gweather_location_unref);
     g_clear_pointer (&brussels, gweather_location_unref);
     _gweather_location_reset_world ();


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