[PATCH] D127807: [clang-tidy] Properly forward clang-tidy output when running tests

Nicolas van Kempen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 15 07:32:28 PDT 2022


nicovank updated this revision to Diff 437163.
nicovank added a comment.

Looks like this causes the `misc-misleading-identifier` test to fail on the BuildKite Windows setup because it uses cp1252 and not utf-8. I think this is why the encode was added in the first place. This workaround should hopefully fix this, it will display unicode characters as '?' when stdout does not support utf-8.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127807/new/

https://reviews.llvm.org/D127807

Files:
  clang-tools-extra/test/clang-tidy/check_clang_tidy.py


Index: clang-tools-extra/test/clang-tidy/check_clang_tidy.py
===================================================================
--- clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -173,13 +173,13 @@
     print('Running ' + repr(args) + '...')
     clang_tidy_output = try_run(args)
     print('------------------------ clang-tidy output -----------------------')
-    print(clang_tidy_output.encode())
-    print('\n------------------------------------------------------------------')
+    print(clang_tidy_output.encode(sys.stdout.encoding, errors="replace").decode(sys.stdout.encoding))
+    print('------------------------------------------------------------------')
 
     diff_output = try_run(['diff', '-u', self.original_file_name, self.temp_file_name], False)
-    print('------------------------------ Fixes -----------------------------\n' +
-          diff_output +
-          '\n------------------------------------------------------------------')
+    print('------------------------------ Fixes -----------------------------')
+    print(diff_output)
+    print('------------------------------------------------------------------')
     return clang_tidy_output
 
   def check_fixes(self):


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127807.437163.patch
Type: text/x-patch
Size: 1272 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220615/5be25455/attachment.bin>


More information about the cfe-commits mailing list