[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
Tue Jun 14 17:01:25 PDT 2022


nicovank created this revision.
Herald added a subscriber: xazax.hun.
Herald added a project: All.
nicovank retitled this revision from "[clang-tidy] Remove encode when outputting tool ouput running tests" to "[clang-tidy] Properly forward clang-tidy output when running tests".
nicovank updated this revision to Diff 436977.
nicovank added a comment.
nicovank published this revision for review.
nicovank added reviewers: rnk, alexfh.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Rebase.


When running tests, the check_clang_tidy script encodes the output string, making it hard to read when debugging checks. This removes the `.encode()` call.

Test Plan:
Making a new default check for testing (as of right now, it includes a failing test):

  [~/llvm-project/clang-tools-extra] python3 clang-tidy/add_new_check.py bugprone example
  <...>

Pre-changes:

  [~/llvm-project/build] ninja check-clang-tools
  <...>
  ------------------------ clang-tidy output -----------------------
  b"1 warning generated.\n/data/users/nvankempen/llvm-project/build/Debug/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-example.cpp.tmp.cpp:4:6: warning: function 'f' is insufficiently awesome [bugprone-example]\nvoid f();\n     ^\n/data/users/nvankempen/llvm-project/build/Debug/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-example.cpp.tmp.cpp:4:6: note: insert 'awesome'\nvoid f();\n     ^\n     awesome_\n"
  
  ------------------------------------------------------------------
  <...>

Post-changes:

  [~/llvm-project/build] ninja check-clang-tools
  <...>
  ------------------------ clang-tidy output -----------------------
  1 warning generated.
  /data/users/nvankempen/llvm-project/build/Debug/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-example.cpp.tmp.cpp:4:6: warning: function 'f' is insufficiently awesome [bugprone-example]
  void f();
       ^
  /data/users/nvankempen/llvm-project/build/Debug/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-example.cpp.tmp.cpp:4:6: note: insert 'awesome'
  void f();
       ^
       awesome_
  
  ------------------------------------------------------------------
  <...>


Repository:
  rG LLVM Github Monorepo

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)
+    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.436977.patch
Type: text/x-patch
Size: 1198 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220615/ee0efa06/attachment.bin>


More information about the cfe-commits mailing list