GNOME Bugzilla – Bug 748610
Some tests fail with non-English locales
Last modified: 2017-10-26 11:07:50 UTC
There are 4 failing tests in glib/tests when using a non-English locales because they check whether the translated messages are expected. I have a patch that adds g_setenv ("LC_ALL", "C", TRUE); to fix the problem.
Created attachment 302539 [details] [review] tests: Fix tests that fail with non-English locales
Comment on attachment 302539 [details] [review] tests: Fix tests that fail with non-English locales >- g_setenv ("LANG", "en_US.utf-8", TRUE); >+ g_setenv ("LC_ALL", "en_US.utf-8", TRUE); Why does LANG not work? Note that option-context.c uses g_setenv("LANG"...) too > test_format_size_for_display (void) > { >+ g_setenv ("LC_ALL", "C", TRUE); > #ifdef G_OS_WIN32 > SetThreadLocale (MAKELCID (MAKELANGID (LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)); > #endif It should do this from main(), like date.c does (because it's not safe to call g_setenv() if other threads are running, and it's difficult to know whether other threads are running or not once the program is doing anything). >+++ b/glib/tests/option-context.c >@@ -2487,6 +2487,7 @@ main (int argc, > int i; > gchar *test_name; > >+ g_setenv ("LC_ALL", "C", TRUE); oh, so that answers part of my LANG-vs-LC_ALL question above. You should remove the existing g_setenv("LANG"...)
Created attachment 302728 [details] [review] tests: Fix tests that fail with non-English locales - always use g_setenv in main (In reply to Dan Winship from comment #2) > Comment on attachment 302539 [details] [review] [review] > tests: Fix tests that fail with non-English locales > > >- g_setenv ("LANG", "en_US.utf-8", TRUE); > >+ g_setenv ("LC_ALL", "en_US.utf-8", TRUE); > > Why does LANG not work? If LC_ALL is already set in the environment, setlocale will use LC_ALL instead of LANG. > > Note that option-context.c uses g_setenv("LANG"...) too > > > test_format_size_for_display (void) > > { > >+ g_setenv ("LC_ALL", "C", TRUE); > > #ifdef G_OS_WIN32 > > SetThreadLocale (MAKELCID (MAKELANGID (LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)); > > #endif > > It should do this from main(), like date.c does (because it's not safe to > call g_setenv() if other threads are running, and it's difficult to know > whether other threads are running or not once the program is doing anything). Fixed in the new patch. > > >+++ b/glib/tests/option-context.c > >@@ -2487,6 +2487,7 @@ main (int argc, > > int i; > > gchar *test_name; > > > >+ g_setenv ("LC_ALL", "C", TRUE); > > oh, so that answers part of my LANG-vs-LC_ALL question above. You should > remove the existing g_setenv("LANG"...)
Comment on attachment 302728 [details] [review] tests: Fix tests that fail with non-English locales - always use g_setenv in main looks good
Attachment 302728 [details] pushed as 5574315 - tests: Fix tests that fail with non-English locales
*** Bug 727920 has been marked as a duplicate of this bug. ***