[libcxx-commits] [libcxx] fix(libcxx/**.py): fix invalid escape sequences (PR #94032)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Jun 1 09:37:31 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 fc21387b6510ee44520f2f17fb671f1265a9055f...29b21653f7d88babe7030c37d2f9fb457b47c37f libcxx/test/libcxx/transitive_includes.gen.py libcxx/utils/generate_escaped_output_table.py libcxx/utils/generate_width_estimation_table.py
``````````
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- test/libcxx/transitive_includes.gen.py 2024-05-31 19:40:43.000000 +0000
+++ test/libcxx/transitive_includes.gen.py 2024-06-01 16:37:06.413866 +0000
@@ -31,39 +31,46 @@
# Note that this needs to be done for all supported language versions of libc++:
# for std in c++03 c++11 c++14 c++17 c++20 c++23 c++26; do <build>/bin/llvm-lit --param std=$std libcxx/test/libcxx/transitive_includes.gen.py; done
regenerate_expected_results = False
if regenerate_expected_results:
- print(f"""\
+ print(
+ f"""\
//--- generate-transitive-includes.sh.cpp
// RUN: mkdir %t
-""")
+"""
+ )
- all_traces = []
- for header in sorted(public_headers):
- if header.endswith('.h'): # Skip C compatibility or detail headers
- continue
+ all_traces = []
+ for header in sorted(public_headers):
+ if header.endswith(".h"): # Skip C compatibility or detail headers
+ continue
- normalized_header = re.sub('/', '_', header)
- print(f"""\
+ normalized_header = re.sub("/", "_", header)
+ print(
+ f"""\
// RUN: echo "#include <{header}>" | %{{cxx}} -xc++ - %{{flags}} %{{compile_flags}} --trace-includes -fshow-skipped-includes --preprocess > /dev/null 2> %t/trace-includes.{normalized_header}.txt
-""")
- all_traces.append(f'%t/trace-includes.{normalized_header}.txt')
+"""
+ )
+ all_traces.append(f"%t/trace-includes.{normalized_header}.txt")
- print(f"""\
+ print(
+ f"""\
// RUN: %{{python}} %{{libcxx-dir}}/test/libcxx/transitive_includes_to_csv.py {' '.join(all_traces)} > %{{libcxx-dir}}/test/libcxx/transitive_includes/%{{cxx_std}}.csv
-""")
+"""
+ )
else:
- for header in public_headers:
- if header.endswith('.h'): # Skip C compatibility or detail headers
- continue
+ for header in public_headers:
+ if header.endswith(".h"): # Skip C compatibility or detail headers
+ continue
- # Escape slashes for the awk command below
- escaped_header = header.replace('/', r'\/')
+ # Escape slashes for the awk command below
+ escaped_header = header.replace("/", r"\/")
- print(f"""\
+ print(
+ f"""\
//--- {header}.sh.cpp
{lit_header_restrictions.get(header, '')}
// TODO: Fix this test to make it work with localization or wide characters disabled
// UNSUPPORTED: no-localization, no-wide-characters, no-threads, no-filesystem, libcpp-has-no-experimental-tzdb, no-tzdb
@@ -87,6 +94,7 @@
// RUN: %{{cxx}} %s %{{flags}} %{{compile_flags}} --trace-includes -fshow-skipped-includes --preprocess > /dev/null 2> %t/trace-includes.txt
// RUN: %{{python}} %{{libcxx-dir}}/test/libcxx/transitive_includes_to_csv.py %t/trace-includes.txt > %t/actual_transitive_includes.csv
// RUN: cat %{{libcxx-dir}}/test/libcxx/transitive_includes/%{{cxx_std}}.csv | awk '/^{escaped_header} / {{ print }}' > %t/expected_transitive_includes.csv
// RUN: diff -w %t/expected_transitive_includes.csv %t/actual_transitive_includes.csv
#include <{header}>
-""")
+"""
+ )
``````````
</details>
https://github.com/llvm/llvm-project/pull/94032
More information about the libcxx-commits
mailing list