mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-09 04:15:49 +01:00
Remove setenv() use from GSettings l10n tests
This definitely does not do anything on Linux. I bet it's not needed on other platforms, either. It's unsafe and may crash; there is no safe way to mutate the environment in threaded programs.
This commit is contained in:
parent
92de7298c8
commit
736000e49e
@ -776,17 +776,14 @@ test_l10n (void)
|
|||||||
|
|
||||||
settings = g_settings_new ("org.gtk.test.localized");
|
settings = g_settings_new ("org.gtk.test.localized");
|
||||||
|
|
||||||
g_setenv ("LC_MESSAGES", "C", TRUE);
|
|
||||||
setlocale (LC_MESSAGES, "C");
|
setlocale (LC_MESSAGES, "C");
|
||||||
str = g_settings_get_string (settings, "error-message");
|
str = g_settings_get_string (settings, "error-message");
|
||||||
g_setenv ("LC_MESSAGES", locale, TRUE);
|
|
||||||
setlocale (LC_MESSAGES, locale);
|
setlocale (LC_MESSAGES, locale);
|
||||||
|
|
||||||
g_assert_cmpstr (str, ==, "Unnamed");
|
g_assert_cmpstr (str, ==, "Unnamed");
|
||||||
g_free (str);
|
g_free (str);
|
||||||
str = NULL;
|
str = NULL;
|
||||||
|
|
||||||
g_setenv ("LC_MESSAGES", "de_DE.UTF-8", TRUE);
|
|
||||||
setlocale (LC_MESSAGES, "de_DE.UTF-8");
|
setlocale (LC_MESSAGES, "de_DE.UTF-8");
|
||||||
/* Only do the test if translation is actually working... */
|
/* Only do the test if translation is actually working... */
|
||||||
if (g_str_equal (dgettext ("test", "\"Unnamed\""), "\"Unbenannt\""))
|
if (g_str_equal (dgettext ("test", "\"Unnamed\""), "\"Unbenannt\""))
|
||||||
@ -802,7 +799,6 @@ test_l10n (void)
|
|||||||
g_test_skip ("translation is not working");
|
g_test_skip ("translation is not working");
|
||||||
}
|
}
|
||||||
|
|
||||||
g_setenv ("LC_MESSAGES", locale, TRUE);
|
|
||||||
setlocale (LC_MESSAGES, locale);
|
setlocale (LC_MESSAGES, locale);
|
||||||
g_free (locale);
|
g_free (locale);
|
||||||
g_object_unref (settings);
|
g_object_unref (settings);
|
||||||
@ -829,17 +825,14 @@ test_l10n_context (void)
|
|||||||
|
|
||||||
settings = g_settings_new ("org.gtk.test.localized");
|
settings = g_settings_new ("org.gtk.test.localized");
|
||||||
|
|
||||||
g_setenv ("LC_MESSAGES", "C", TRUE);
|
|
||||||
setlocale (LC_MESSAGES, "C");
|
setlocale (LC_MESSAGES, "C");
|
||||||
g_settings_get (settings, "backspace", "s", &str);
|
g_settings_get (settings, "backspace", "s", &str);
|
||||||
g_setenv ("LC_MESSAGES", locale, TRUE);
|
|
||||||
setlocale (LC_MESSAGES, locale);
|
setlocale (LC_MESSAGES, locale);
|
||||||
|
|
||||||
g_assert_cmpstr (str, ==, "BackSpace");
|
g_assert_cmpstr (str, ==, "BackSpace");
|
||||||
g_free (str);
|
g_free (str);
|
||||||
str = NULL;
|
str = NULL;
|
||||||
|
|
||||||
g_setenv ("LC_MESSAGES", "de_DE.UTF-8", TRUE);
|
|
||||||
setlocale (LC_MESSAGES, "de_DE.UTF-8");
|
setlocale (LC_MESSAGES, "de_DE.UTF-8");
|
||||||
/* Only do the test if translation is actually working... */
|
/* Only do the test if translation is actually working... */
|
||||||
if (g_str_equal (dgettext ("test", "\"Unnamed\""), "\"Unbenannt\""))
|
if (g_str_equal (dgettext ("test", "\"Unnamed\""), "\"Unbenannt\""))
|
||||||
@ -847,7 +840,6 @@ test_l10n_context (void)
|
|||||||
else
|
else
|
||||||
g_test_skip ("translation is not working");
|
g_test_skip ("translation is not working");
|
||||||
|
|
||||||
g_setenv ("LC_MESSAGES", locale, TRUE);
|
|
||||||
setlocale (LC_MESSAGES, locale);
|
setlocale (LC_MESSAGES, locale);
|
||||||
g_free (locale);
|
g_free (locale);
|
||||||
g_object_unref (settings);
|
g_object_unref (settings);
|
||||||
@ -871,17 +863,14 @@ test_l10n_time (void)
|
|||||||
|
|
||||||
settings = g_settings_new ("org.gtk.test.localized");
|
settings = g_settings_new ("org.gtk.test.localized");
|
||||||
|
|
||||||
g_setenv ("LC_TIME", "C", TRUE);
|
|
||||||
setlocale (LC_TIME, "C");
|
setlocale (LC_TIME, "C");
|
||||||
str = g_settings_get_string (settings, "midnight");
|
str = g_settings_get_string (settings, "midnight");
|
||||||
g_setenv ("LC_TIME", locale, TRUE);
|
|
||||||
setlocale (LC_TIME, locale);
|
setlocale (LC_TIME, locale);
|
||||||
|
|
||||||
g_assert_cmpstr (str, ==, "12:00 AM");
|
g_assert_cmpstr (str, ==, "12:00 AM");
|
||||||
g_free (str);
|
g_free (str);
|
||||||
str = NULL;
|
str = NULL;
|
||||||
|
|
||||||
g_setenv ("LC_TIME", "de_DE.UTF-8", TRUE);
|
|
||||||
setlocale (LC_TIME, "de_DE.UTF-8");
|
setlocale (LC_TIME, "de_DE.UTF-8");
|
||||||
/* Only do the test if translation is actually working... */
|
/* Only do the test if translation is actually working... */
|
||||||
if (g_str_equal (dgettext ("test", "\"12:00 AM\""), "\"00:00\""))
|
if (g_str_equal (dgettext ("test", "\"12:00 AM\""), "\"00:00\""))
|
||||||
@ -897,7 +886,6 @@ test_l10n_time (void)
|
|||||||
g_test_skip ("translation is not working");
|
g_test_skip ("translation is not working");
|
||||||
}
|
}
|
||||||
|
|
||||||
g_setenv ("LC_TIME", locale, TRUE);
|
|
||||||
setlocale (LC_TIME, locale);
|
setlocale (LC_TIME, locale);
|
||||||
g_free (locale);
|
g_free (locale);
|
||||||
g_object_unref (settings);
|
g_object_unref (settings);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user