Index: base/test/test_suite.cc |
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc |
index 903e93ea07a7b8aba49e66f49603dcda88bdae89..d40dd983eb6b143fdbf97466ce25e66ec2be92dc 100644 |
--- a/base/test/test_suite.cc |
+++ b/base/test/test_suite.cc |
@@ -35,6 +35,14 @@ |
#endif // OS_IOS |
#endif // OS_MACOSX |
+#if !defined(OS_WIN) |
+#include "base/i18n/rtl.h" |
+#if !defined(OS_IOS) |
+#include "base/strings/string_util.h" |
+#include "third_party/icu/source/common/unicode/uloc.h" |
+#endif |
+#endif |
+ |
#if defined(OS_ANDROID) |
#include "base/test/test_support_android.h" |
#endif |
@@ -321,6 +329,22 @@ void TestSuite::Initialize() { |
} |
base::i18n::InitializeICU(); |
+ // On the Mac OS X command line, the default locale is *_POSIX. In Chromium, |
+ // the locale is set via an OS X locale API and is never *_POSIX. |
+ // Some tests (such as those involving word break iterator) will behave |
+ // differently and fail if we use *POSIX locale. Setting it to en_US here |
+ // does not affect tests that explicitly overrides the locale for testing. |
+ // This can be an issue on all platforms other than Windows. |
+ // TODO(jshin): Should we set the locale via an OS X locale API here? |
+#if !defined(OS_WIN) |
+#if defined(OS_IOS) |
+ base::i18n::SetICUDefaultLocale("en_US"); |
+#else |
+ std::string default_locale(uloc_getDefault()); |
+ if (EndsWith(default_locale, "POSIX", false)) |
+ base::i18n::SetICUDefaultLocale("en_US"); |
+#endif |
+#endif |
CatchMaybeTests(); |
ResetCommandLine(); |