[pango/for-master] Skip test-itemize when the en_US locale is missing
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/for-master] Skip test-itemize when the en_US locale is missing
- Date: Mon, 8 Jun 2020 16:37:49 +0000 (UTC)
commit 85167fff28951658fa89b3bcfe13a78176d2a8d7
Author: Emmanuele Bassi <ebassi gnome org>
Date: Mon Jun 8 17:29:28 2020 +0100
Skip test-itemize when the en_US locale is missing
Just like test-layout.
tests/test-itemize.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/tests/test-itemize.c b/tests/test-itemize.c
index 167e4e80..51f2bb9c 100644
--- a/tests/test-itemize.c
+++ b/tests/test-itemize.c
@@ -110,7 +110,7 @@ test_file (const gchar *filename, GString *string)
gchar *contents;
gsize length;
GError *error = NULL;
- GString *s1, *s2, *s3, *s4, *s5, *s6;
+ GString *s1, *s2, *s3, *s4, *s5, *s6;
char *test;
char *text;
PangoAttrList *attrs;
@@ -237,6 +237,16 @@ test_itemize (gconstpointer d)
GString *dump;
gchar *diff;
+ const char *old_locale = setlocale (LC_ALL, NULL);
+ setlocale (LC_ALL, "en_US.UTF-8");
+ if (strstr (setlocale (LC_ALL, NULL), "en_US") == NULL)
+ {
+ char *msg = g_strdup_printf ("Locale en_US.UTF-8 not available, skipping itemization %s", filename);
+ g_test_skip (msg);
+ g_free (msg);
+ return;
+ }
+
expected_file = get_expected_filename (filename);
dump = g_string_sized_new (0);
@@ -256,6 +266,8 @@ test_itemize (gconstpointer d)
g_string_free (dump, TRUE);
g_free (expected_file);
+
+ setlocale (LC_ALL, old_locale);
}
int
@@ -266,9 +278,6 @@ main (int argc, char *argv[])
const gchar *name;
gchar *path;
- g_setenv ("LC_ALL", "en_US.UTF-8", TRUE);
- setlocale (LC_ALL, "");
-
g_test_init (&argc, &argv, NULL);
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]