From e9a6609b7d4aedffa9109bb26ce1bee31d92dbb6 Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Fri, 20 Oct 2023 02:13:04 -0700 Subject: [PATCH 1/5] If INDUCE_FAILURE_IN_FORMATTER appears in file list, cause darker/clang-format failure --- llvm/utils/git/code-format-helper.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/llvm/utils/git/code-format-helper.py b/llvm/utils/git/code-format-helper.py index c45bb4d935d47..db2d4c5c52273 100644 --- a/llvm/utils/git/code-format-helper.py +++ b/llvm/utils/git/code-format-helper.py @@ -148,6 +148,11 @@ def format_run( args.end_rev, "--", ] + cpp_files + + # For manual testing purposes... + if "INDUCE_FAILURE_IN_FORMATTER" in " ".join(cpp_files): + cf_cmd.insert(1, "--induce-failure") + print(f"Running: {' '.join(cf_cmd)}") self.cf_cmd = cf_cmd proc = subprocess.run(cf_cmd, capture_output=True) @@ -192,6 +197,11 @@ def format_run( "-r", f"{args.start_rev}..{args.end_rev}", ] + py_files + + # For manual testing purposes... + if "INDUCE_FAILURE_IN_FORMATTER" in " ".join(py_files): + darker_cmd += ["--induce-failure"] + print(f"Running: {' '.join(darker_cmd)}") self.darker_cmd = darker_cmd proc = subprocess.run(darker_cmd, capture_output=True) From 5204c7273fcce1b4beddbc01996f9ec5857f5cec Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Fri, 20 Oct 2023 03:42:26 -0700 Subject: [PATCH 2/5] Test the C++ formatter: ignored file and broken file Test the Python formatter: an OK change --- libcxx/test/support/test.support/type_algorithms.pass.cpp | 6 ++++++ llvm/utils/git/test3.cpp | 6 ++++++ llvm/utils/git/test3.py | 4 ++++ 3 files changed, 16 insertions(+) create mode 100644 llvm/utils/git/test3.cpp create mode 100644 llvm/utils/git/test3.py diff --git a/libcxx/test/support/test.support/type_algorithms.pass.cpp b/libcxx/test/support/test.support/type_algorithms.pass.cpp index cf6144d1cb04f..4a76f58f879af 100644 --- a/libcxx/test/support/test.support/type_algorithms.pass.cpp +++ b/libcxx/test/support/test.support/type_algorithms.pass.cpp @@ -13,6 +13,12 @@ #include "test_macros.h" #include "type_algorithms.h" +int some_file( void ) { + + return 1+2; // three! + +} + // concatenate static_assert(std::is_same >, types::type_list<> >::value, ""); static_assert(std::is_same >, types::type_list >::value, ""); diff --git a/llvm/utils/git/test3.cpp b/llvm/utils/git/test3.cpp new file mode 100644 index 0000000000000..233b363c48c39 --- /dev/null +++ b/llvm/utils/git/test3.cpp @@ -0,0 +1,6 @@ +int three() { + if(code) + { + return 1+2; + } +} \ No newline at end of file diff --git a/llvm/utils/git/test3.py b/llvm/utils/git/test3.py new file mode 100644 index 0000000000000..059c5a7f95d10 --- /dev/null +++ b/llvm/utils/git/test3.py @@ -0,0 +1,4 @@ +import sys + +if __name__ == "__main__": + sys.exit(42) From 295bcf467cdb84d05bb8ca0d9c2df5651f64c151 Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Fri, 20 Oct 2023 03:59:55 -0700 Subject: [PATCH 3/5] cause formatters to fail --- llvm/utils/git/INDUCE_FAILURE_IN_FORMATTER_2.cpp | 0 llvm/utils/git/INDUCE_FAILURE_IN_FORMATTER_2.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 llvm/utils/git/INDUCE_FAILURE_IN_FORMATTER_2.cpp create mode 100644 llvm/utils/git/INDUCE_FAILURE_IN_FORMATTER_2.py diff --git a/llvm/utils/git/INDUCE_FAILURE_IN_FORMATTER_2.cpp b/llvm/utils/git/INDUCE_FAILURE_IN_FORMATTER_2.cpp new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/llvm/utils/git/INDUCE_FAILURE_IN_FORMATTER_2.py b/llvm/utils/git/INDUCE_FAILURE_IN_FORMATTER_2.py new file mode 100644 index 0000000000000..e69de29bb2d1d From c6f55bd2fc55198fddafecc299879d91796efcaa Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Fri, 20 Oct 2023 04:16:49 -0700 Subject: [PATCH 4/5] remove failures, fix test3.cpp --- llvm/utils/git/INDUCE_FAILURE_IN_FORMATTER_2.cpp | 0 llvm/utils/git/INDUCE_FAILURE_IN_FORMATTER_2.py | 0 llvm/utils/git/test3.cpp | 7 +++---- 3 files changed, 3 insertions(+), 4 deletions(-) delete mode 100644 llvm/utils/git/INDUCE_FAILURE_IN_FORMATTER_2.cpp delete mode 100644 llvm/utils/git/INDUCE_FAILURE_IN_FORMATTER_2.py diff --git a/llvm/utils/git/INDUCE_FAILURE_IN_FORMATTER_2.cpp b/llvm/utils/git/INDUCE_FAILURE_IN_FORMATTER_2.cpp deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/llvm/utils/git/INDUCE_FAILURE_IN_FORMATTER_2.py b/llvm/utils/git/INDUCE_FAILURE_IN_FORMATTER_2.py deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/llvm/utils/git/test3.cpp b/llvm/utils/git/test3.cpp index 233b363c48c39..e8fbefca2e354 100644 --- a/llvm/utils/git/test3.cpp +++ b/llvm/utils/git/test3.cpp @@ -1,6 +1,5 @@ int three() { - if(code) - { - return 1+2; + if (code) { + return 1 + 2; } -} \ No newline at end of file +} From 8c6fc8beaa54b22edecc73106150d72487a6674f Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Fri, 20 Oct 2023 04:20:27 -0700 Subject: [PATCH 5/5] remove newline --- llvm/utils/git/test3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/utils/git/test3.cpp b/llvm/utils/git/test3.cpp index e8fbefca2e354..bec7d2853956b 100644 --- a/llvm/utils/git/test3.cpp +++ b/llvm/utils/git/test3.cpp @@ -2,4 +2,4 @@ int three() { if (code) { return 1 + 2; } -} +} \ No newline at end of file