[libcxx] [llvm] [libcxx] Provide locale conversions to tests through lit substitution (PR #86649)

via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 26 03:54:19 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {darker}-->


:warning: Python code formatter, darker found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
darker --check --diff -r 6a6f9bf38e65ec45b32da4b578e2830341a9b364...ea03aea1148e581983aa667a2728fdac9a9a12b5 libcxx/utils/libcxx/test/features.py llvm/utils/lit/lit/TestRunner.py
``````````

</details>

<details>
<summary>
View the diff from darker here.
</summary>

``````````diff
--- libcxx/utils/libcxx/test/features.py	2024-03-26 10:08:18.000000 +0000
+++ libcxx/utils/libcxx/test/features.py	2024-03-26 10:23:41.146995 +0000
@@ -345,22 +345,25 @@
     # 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),
-            actions=lambda cfg, locale=locale, alts=alts:
-                _getLocaleFlagsAction(cfg, locale, alts, provide_locale_conversions[locale])
-                if locale in provide_locale_conversions
-                   and "_LIBCPP_HAS_NO_WIDE_CHARACTERS" not in compilerMacros(cfg) else []
+            actions=lambda cfg, locale=locale, alts=alts: _getLocaleFlagsAction(
+                cfg, locale, alts, provide_locale_conversions[locale]
+            )
+            if locale in provide_locale_conversions
+            and "_LIBCPP_HAS_NO_WIDE_CHARACTERS" not in compilerMacros(cfg)
+            else [],
         ),
     )
+
 
 # Provide environment locale conversions through substitutions to avoid platform specific
 # maintenance.
 def _getLocaleFlagsAction(cfg, locale, alts, members):
     alts_list = ",".join([f'"{l}"' for l in alts])
-    get_member_list = ",".join([f'lc->{m}' for m in members])
+    get_member_list = ",".join([f"lc->{m}" for m in members])
 
     localeconv_info = programOutput(
         cfg,
         r"""
         #if defined(_WIN32) && !defined(_CRT_SECURE_NO_WARNINGS)
@@ -408,23 +411,25 @@
             return 0;
           }
 
           return 1;
         }
-        """ % (alts_list, len(alts), get_member_list, len(members)),
+        """
+        % (alts_list, len(alts), get_member_list, len(members)),
     )
     if not substitutionsWillEscapeBackslashes():
         # Account for different escaping depending on platform running lit
         localeconv_info = localeconv_info.replace("\\", "\\\\")
     valid_define_name = re.sub(r"[.-]", "_", locale).upper()
     return [
         # Provide locale conversion through a substitution.
         # Example: %{LOCALE_CONV_FR_FR_UTF_8_THOUSANDS_SEP} = L"\u202f"
         AddSubstitution(
-            f'%{{LOCALE_CONV_{valid_define_name}_{member.upper()}}}',
-            lambda cfg, value=value: f'\'L"{value}"\''
-        ) for member, value in zip(members, localeconv_info.split('\n'))
+            f"%{{LOCALE_CONV_{valid_define_name}_{member.upper()}}}",
+            lambda cfg, value=value: f"'L\"{value}\"'",
+        )
+        for member, value in zip(members, localeconv_info.split("\n"))
     ]
 
 
 # Add features representing the target platform name: darwin, linux, windows, etc...
 DEFAULT_FEATURES += [

``````````

</details>


https://github.com/llvm/llvm-project/pull/86649


More information about the llvm-commits mailing list