[libcxx-commits] [libcxx] [libc++] Refactor the conditions for enabling assertion tests (PR #213294)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jul 31 08:40:37 PDT 2026


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 origin/main...HEAD libcxx/utils/libcxx/test/features/hardening.py libcxx/utils/libcxx/test/features/__init__.py libcxx/utils/libcxx/test/features/libcxx_macros.py libcxx/utils/libcxx/test/params.py
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

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

``````````diff
--- features/__init__.py	2026-07-31 15:37:44.000000 +0000
+++ features/__init__.py	2026-07-31 15:39:54.023582 +0000
@@ -4,11 +4,20 @@
 # See https://llvm.org/LICENSE.txt for license information.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 #
 # ===----------------------------------------------------------------------===##
 
-from . import availability, compiler, gdb, hardening, libcxx_macros, localization, misc, platform
+from . import (
+    availability,
+    compiler,
+    gdb,
+    hardening,
+    libcxx_macros,
+    localization,
+    misc,
+    platform,
+)
 
 # Lit features are evaluated in order. Some features depend on other features, so
 # we are careful to define them in the correct order. For example, several features
 # require the compiler detection to have been performed.
 DEFAULT_FEATURES = []
@@ -17,6 +26,8 @@
 DEFAULT_FEATURES += platform.features
 DEFAULT_FEATURES += localization.features
 DEFAULT_FEATURES += gdb.features
 DEFAULT_FEATURES += misc.features
 DEFAULT_FEATURES += availability.features
-DEFAULT_FEATURES += hardening.features # this depends on availability, misc and libc++ macro features
+DEFAULT_FEATURES += (
+    hardening.features
+)  # this depends on availability, misc and libc++ macro features
--- features/hardening.py	2026-07-31 15:37:44.000000 +0000
+++ features/hardening.py	2026-07-31 15:39:54.046887 +0000
@@ -28,11 +28,11 @@
         }}
     """
     features.append(
         Feature(
             name=f"libcpp-hardening-mode={mode}",
-            when=lambda cfg, prog=check_program: programSucceeds(cfg, prog)
+            when=lambda cfg, prog=check_program: programSucceeds(cfg, prog),
         )
     )
 
 # Detect the assertion semantic used by hardening as `libcpp-assertion-semantic=<semantic>`.
 #
@@ -52,11 +52,11 @@
         }}
     """
     features.append(
         Feature(
             name=f"libcpp-assertion-semantic={semantic}",
-            when=lambda cfg, prog=check_program: programSucceeds(cfg, prog)
+            when=lambda cfg, prog=check_program: programSucceeds(cfg, prog),
         )
     )
 
 # Whether the test suite is able to check that hardening assertions fire.
 #
@@ -102,12 +102,16 @@
     "fast": ("fast", "extensive", "debug"),
     "extensive": ("extensive", "debug"),
     "debug": ("debug",),
 }
 for category, modes in enabling_modes.items():
-    expression = "can-test-hardening-assertions && ({})".format(" || ".join(f"libcpp-hardening-mode={mode}" for mode in modes))
+    expression = "can-test-hardening-assertions && ({})".format(
+        " || ".join(f"libcpp-hardening-mode={mode}" for mode in modes)
+    )
     features.append(
         Feature(
             name=f"can-test-hardening-assertions-{category}",
-            when=lambda cfg, expr=expression: BooleanExpression.evaluate(expr, cfg.available_features)
+            when=lambda cfg, expr=expression: BooleanExpression.evaluate(
+                expr, cfg.available_features
+            ),
         )
     )

``````````

</details>


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


More information about the libcxx-commits mailing list