[libcxx-commits] [libcxx] [libc++][C++03] Split libc++-specific tests for the frozen headers (PR #144093)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jun 13 08:30:20 PDT 2025


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 HEAD~1...HEAD libcxx/test/libcxx-03/clang_modules_include.gen.py libcxx/test/libcxx-03/clang_tidy.gen.py libcxx/test/libcxx-03/clang_tidy.sh.py libcxx/test/libcxx-03/double_include.gen.py libcxx/test/libcxx-03/feature_test_macro/ftm_metadata.sh.py libcxx/test/libcxx-03/feature_test_macro/generate_header_test.sh.py libcxx/test/libcxx-03/feature_test_macro/implemented_ftms.sh.py libcxx/test/libcxx-03/feature_test_macro/invalid.sh.py libcxx/test/libcxx-03/feature_test_macro/is_implemented.sh.py libcxx/test/libcxx-03/feature_test_macro/standard_ftms.sh.py libcxx/test/libcxx-03/feature_test_macro/standard_library_headers.sh.py libcxx/test/libcxx-03/feature_test_macro/std_dialects.sh.py libcxx/test/libcxx-03/feature_test_macro/version_header.sh.py libcxx/test/libcxx-03/feature_test_macro/version_header_implementation.sh.py libcxx/test/libcxx-03/gdb/gdb_pretty_printer_test.py libcxx/test/libcxx-03/header_inclusions.gen.py libcxx/test/libcxx-03/headers_in_modulemap.sh.py libcxx/test/libcxx-03/libcpp_version.gen.py libcxx/test/libcxx-03/lint/lint_cmakelists.sh.py libcxx/test/libcxx-03/lint/lint_headers.sh.py libcxx/test/libcxx-03/module_std.gen.py libcxx/test/libcxx-03/module_std_compat.gen.py libcxx/test/libcxx-03/no_assert_include.gen.py libcxx/test/libcxx-03/selftest/dsl/dsl.sh.py libcxx/test/libcxx-03/system_reserved_names.gen.py libcxx/test/libcxx-03/transitive_includes.gen.py libcxx/test/libcxx-03/transitive_includes/to_csv.py libcxx/test/libcxx-03/xopen_source.gen.py
``````````

</details>

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

``````````diff
--- clang_modules_include.gen.py	2025-06-13 15:24:09.000000 +0000
+++ clang_modules_include.gen.py	2025-06-13 15:29:32.426876 +0000
@@ -14,10 +14,11 @@
 
 # block Lit from interpreting a RUN/XFAIL/etc inside the generation script
 # END.
 
 import sys
+
 sys.path.append(sys.argv[1])
 from libcxx.header_information import (
     lit_header_restrictions,
     lit_header_undeprecations,
     public_headers,
--- clang_tidy.gen.py	2025-06-13 15:24:09.000000 +0000
+++ clang_tidy.gen.py	2025-06-13 15:29:32.435253 +0000
@@ -13,15 +13,21 @@
 
 # block Lit from interpreting a RUN/XFAIL/etc inside the generation script
 # END.
 
 import sys
+
 sys.path.append(sys.argv[1])
-from libcxx.header_information import lit_header_restrictions, lit_header_undeprecations, public_headers
+from libcxx.header_information import (
+    lit_header_restrictions,
+    lit_header_undeprecations,
+    public_headers,
+)
 
 for header in public_headers:
-  print(f"""\
+    print(
+        f"""\
 //--- {header}.sh.cpp
 
 // REQUIRES: has-clang-tidy
 
 // The frozen headers should not be updated to the latest libc++ style, so don't test.
@@ -35,6 +41,7 @@
 
 // TODO: run clang-tidy with modules enabled once they are supported
 // RUN: %{{clang-tidy}} %s --warnings-as-errors=* -header-filter=.* --config-file=%{{libcxx-dir}}/.clang-tidy --load=%{{test-tools-dir}}/clang_tidy_checks/libcxx-tidy.plugin -- -Wweak-vtables %{{compile_flags}} -fno-modules
 
 #include <{header}>
-""")
+"""
+    )
--- double_include.gen.py	2025-06-13 15:24:09.000000 +0000
+++ double_include.gen.py	2025-06-13 15:29:32.448903 +0000
@@ -12,10 +12,11 @@
 
 # Block Lit from interpreting a RUN/XFAIL/etc inside the generation script.
 # END.
 
 import sys
+
 sys.path.append(sys.argv[1])
 from libcxx.header_information import (
     lit_header_restrictions,
     lit_header_undeprecations,
     public_headers,
--- feature_test_macro/implemented_ftms.sh.py	2025-06-13 15:24:09.000000 +0000
+++ feature_test_macro/implemented_ftms.sh.py	2025-06-13 15:29:32.501056 +0000
@@ -23,11 +23,10 @@
     def setUp(self):
         self.ftm = FeatureTestMacros(TEST_DATA, ["charconv"])
         self.maxDiff = None  # This causes the diff to be printed when the test fails
 
     def test_implementation(self):
-
         expected = {
             "__cpp_lib_any": {
                 "c++17": "201606L",
                 "c++20": "201606L",
                 "c++23": "201606L",
--- headers_in_modulemap.sh.py	2025-06-13 15:24:09.000000 +0000
+++ headers_in_modulemap.sh.py	2025-06-13 15:29:32.633182 +0000
@@ -1,8 +1,9 @@
 # RUN: %{python} %s %{libcxx-dir}/utils
 
 import sys
+
 sys.path.append(sys.argv[1])
 from libcxx.header_information import all_headers, libcxx_include
 
 with open(libcxx_include / "module.modulemap.in") as f:
     modulemap = f.read()
--- libcpp_version.gen.py	2025-06-13 15:24:09.000000 +0000
+++ libcpp_version.gen.py	2025-06-13 15:29:32.641292 +0000
@@ -9,10 +9,11 @@
 # Test that all headers define the _LIBCPP_VERSION macro.
 
 # RUN: %{python} %s %{libcxx-dir}/utils
 
 import sys
+
 sys.path.append(sys.argv[1])
 from libcxx.header_information import (
     lit_header_restrictions,
     lit_header_undeprecations,
     public_headers,
--- selftest/dsl/dsl.sh.py	2025-06-13 15:24:09.000000 +0000
+++ selftest/dsl/dsl.sh.py	2025-06-13 15:29:32.868638 +0000
@@ -308,11 +308,11 @@
 
     def test_basic(self):
         macros = dsl.compilerMacros(self.config)
         self.assertIsInstance(macros, dict)
         self.assertGreater(len(macros), 0)
-        for (k, v) in macros.items():
+        for k, v in macros.items():
             self.assertIsInstance(k, str)
             self.assertIsInstance(v, str)
 
     def test_no_flag(self):
         macros = dsl.compilerMacros(self.config)
@@ -341,11 +341,11 @@
 
     def test_basic(self):
         macros = dsl.featureTestMacros(self.config)
         self.assertIsInstance(macros, dict)
         self.assertGreater(len(macros), 0)
-        for (k, v) in macros.items():
+        for k, v in macros.items():
             self.assertIsInstance(k, str)
             self.assertIsInstance(v, int)
 
 
 class TestFeature(SetupConfigs):
--- transitive_includes/to_csv.py	2025-06-13 15:24:09.000000 +0000
+++ transitive_includes/to_csv.py	2025-06-13 15:29:32.920269 +0000
@@ -14,13 +14,16 @@
 import os
 import pathlib
 import re
 import sys
 
-libcxx_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
+libcxx_root = os.path.dirname(
+    os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+)
 sys.path.append(os.path.join(libcxx_root, "utils"))
 from libcxx.header_information import Header
+
 
 def parse_line(line: str) -> Tuple[int, str]:
     """
     Parse a single line of --trace-includes output.
 
@@ -31,10 +34,11 @@
         raise ArgumentError(f"Line {line} contains invalid data.")
 
     # The number of periods in front of the header name is the nesting level of
     # that header.
     return (len(match.group(1)), match.group(2))
+
 
 def make_cxx_v1_relative(header: str) -> Optional[str]:
     """
     Returns the path of the header as relative to <whatever>/c++/v1, or None if the path
     doesn't contain c++/v1.
@@ -51,10 +55,11 @@
     match = re.match(CXX_V1_REGEX, header)
     if not match:
         return None
     else:
         return match.group(1)
+
 
 def parse_file(file: io.TextIOBase) -> List[Tuple[Header, Header]]:
     """
     Parse a file containing --trace-includes output to generate a list of the
     transitive includes contained in it.
@@ -79,25 +84,27 @@
         else:
             assert includer is not None
             result.append((includer, Header(relative)))
     return result
 
+
 def print_csv(includes: List[Tuple[Header, Header]]) -> None:
     """
     Print the transitive includes as space-delimited CSV.
 
     This function only prints public libc++ headers that are not C compatibility headers.
     """
     # Sort and group by includer
     by_includer = lambda t: t[0]
     includes = itertools.groupby(sorted(includes, key=by_includer), key=by_includer)
 
-    for (includer, includees) in includes:
+    for includer, includees in includes:
         includees = map(lambda t: t[1], includees)
         for h in sorted(set(includees)):
             if h.is_public() and not h.is_C_compatibility():
                 print(f"{includer} {h}")
+
 
 def main(argv):
     parser = argparse.ArgumentParser(
         description="""
         Given a list of headers produced by --trace-includes, produce a list of libc++ headers in that output.
@@ -106,15 +113,22 @@
         information for this script to run.
 
         The output of this script is provided in space-delimited CSV format where each line contains:
 
             <header performing inclusion> <header being included>
-        """)
-    parser.add_argument("inputs", type=argparse.FileType("r"), nargs='+', default=None,
-        help="One or more files containing the result of --trace-includes")
+        """
+    )
+    parser.add_argument(
+        "inputs",
+        type=argparse.FileType("r"),
+        nargs="+",
+        default=None,
+        help="One or more files containing the result of --trace-includes",
+    )
     args = parser.parse_args(argv)
 
     includes = [line for file in args.inputs for line in parse_file(file)]
     print_csv(includes)
 
+
 if __name__ == "__main__":
     main(sys.argv[1:])
--- transitive_includes.gen.py	2025-06-13 15:24:09.000000 +0000
+++ transitive_includes.gen.py	2025-06-13 15:29:32.937220 +0000
@@ -20,10 +20,11 @@
 
 # block Lit from interpreting a RUN/XFAIL/etc inside the generation script
 # END.
 
 import sys
+
 sys.path.append(sys.argv[1])
 from libcxx.header_information import lit_header_restrictions, public_headers
 
 import re
 

``````````

</details>


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


More information about the libcxx-commits mailing list