diff --git a/libcxx/test/std/containers/container.adaptors/container.adaptors.format/format.functions.tests.h b/libcxx/test/std/containers/container.adaptors/container.adaptors.format/format.functions.tests.h --- a/libcxx/test/std/containers/container.adaptors/container.adaptors.format/format.functions.tests.h +++ b/libcxx/test/std/containers/container.adaptors/container.adaptors.format/format.functions.tests.h @@ -600,16 +600,17 @@ // *** locale-specific form *** check(SV("[-42.5, 0, 1.25, 42.5]"), SV("{::L}"), input); // does not require locales present #ifndef TEST_HAS_NO_LOCALIZATION -// TODO FMT Enable with locale testing active -# if 0 +# ifdef TEST_HAS_LOCALE_fr_FR_UTF_8 std::locale::global(std::locale(LOCALE_fr_FR_UTF_8)); check(SV("[-42,5, 0, 1,25, 42,5]"), SV("{::L}"), input); +# endif +# ifdef TEST_HAS_LOCALE_en_US_UTF_8 std::locale::global(std::locale(LOCALE_en_US_UTF_8)); check(SV("[-42.5, 0, 1.25, 42.5]"), SV("{::L}"), input); +# endif std::locale::global(std::locale::classic()); -# endif #endif // TEST_HAS_NO_LOCALIZATION // *** type *** diff --git a/libcxx/test/std/utilities/format/format.range/format.range.fmtset/format.functions.tests.h b/libcxx/test/std/utilities/format/format.range/format.range.fmtset/format.functions.tests.h --- a/libcxx/test/std/utilities/format/format.range/format.range.fmtset/format.functions.tests.h +++ b/libcxx/test/std/utilities/format/format.range/format.range.fmtset/format.functions.tests.h @@ -776,16 +776,17 @@ // *** locale-specific form *** check(SV("{-42.5, 0, 1.25, 42.5}"), SV("{::L}"), input); // does not require locales present #ifndef TEST_HAS_NO_LOCALIZATION -// TODO FMT Enable with locale testing active -# if 0 +# ifdef TEST_HAS_LOCALE_fr_FR_UTF_8 std::locale::global(std::locale(LOCALE_fr_FR_UTF_8)); check(SV("{-42,5, 0, 1,25, 42,5}"), SV("{::L}"), input); +# endif +# ifdef TEST_HAS_LOCALE_en_US_UTF_8 std::locale::global(std::locale(LOCALE_en_US_UTF_8)); check(SV("{-42.5, 0, 1.25, 42.5}"), SV("{::L}"), input); +# endif std::locale::global(std::locale::classic()); -# endif #endif // TEST_HAS_NO_LOCALIZATION // *** type *** diff --git a/libcxx/test/std/utilities/format/format.range/format.range.formatter/format.functions.tests.h b/libcxx/test/std/utilities/format/format.range/format.range.formatter/format.functions.tests.h --- a/libcxx/test/std/utilities/format/format.range/format.range.formatter/format.functions.tests.h +++ b/libcxx/test/std/utilities/format/format.range/format.range.formatter/format.functions.tests.h @@ -587,16 +587,17 @@ // *** locale-specific form *** check(SV("[-42.5, 0, 1.25, 42.5]"), SV("{::L}"), input); // does not require locales present #ifndef TEST_HAS_NO_LOCALIZATION -// TODO FMT Enable with locale testing active -# if 0 +# ifdef TEST_HAS_LOCALE_fr_FR_UTF_8 std::locale::global(std::locale(LOCALE_fr_FR_UTF_8)); check(SV("[-42,5, 0, 1,25, 42,5]"), SV("{::L}"), input); +# endif +# ifdef TEST_HAS_LOCALE_en_US_UTF_8 std::locale::global(std::locale(LOCALE_en_US_UTF_8)); check(SV("[-42.5, 0, 1.25, 42.5]"), SV("{::L}"), input); +# endif std::locale::global(std::locale::classic()); -# endif #endif // TEST_HAS_NO_LOCALIZATION // *** type *** diff --git a/libcxx/test/support/platform_support.h b/libcxx/test/support/platform_support.h --- a/libcxx/test/support/platform_support.h +++ b/libcxx/test/support/platform_support.h @@ -17,6 +17,10 @@ #include "test_macros.h" // locale names +// +// An alternative would be to only define these macros when the test suceeds, +// that would result in compilation error instead of runtime errors +// #define LOCALE_en_US_UTF_8 "en_US.UTF-8" #define LOCALE_fr_FR_UTF_8 "fr_FR.UTF-8" #ifdef __linux__ diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py --- a/libcxx/utils/libcxx/test/features.py +++ b/libcxx/utils/libcxx/test/features.py @@ -240,7 +240,8 @@ # Note: Using alts directly in the lambda body here will bind it to the value at the # end of the loop. Assigning it to a default argument works around this issue. DEFAULT_FEATURES.append(Feature(name='locale.{}'.format(locale), - when=lambda cfg, alts=alts: hasAnyLocale(cfg, alts))) + when=lambda cfg, alts=alts: hasAnyLocale(cfg, alts), + actions=[AddCompileFlag('-DTEST_HAS_LOCALE_{}'.format(re.sub("\W", "_", locale)))])) # Add features representing the target platform name: darwin, linux, windows, etc...