llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-tools-extra Author: Baranov Victor (vbvictor) <details> <summary>Changes</summary> clang-tidy-diff.py unconditionally wrote `stdout + "\n"` for every file it processed, even when clang-tidy produced no output so this bloated output with needless blank line (happened with `-quiet` flag enabled which made tidy produce 0 diagnostics). --- Full diff: https://github.com/llvm/llvm-project/pull/213873.diff 3 Files Affected: - (modified) clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py (+3-2) - (added) clang-tools-extra/test/clang-tidy/infrastructure/Inputs/clang-tidy-diff/test.cpp (+1) - (modified) clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-diff.cpp (+8) ``````````diff diff --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py index 07f2b911a03a2..059b2a2e8f476 100755 --- a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py +++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py @@ -68,8 +68,9 @@ def run_tidy(task_queue, lock, timeout, failed_files): failed_files.append(command) with lock: - sys.stdout.write(stdout.decode("utf-8") + "\n") - sys.stdout.flush() + if stdout: + sys.stdout.write(stdout.decode("utf-8") + "\n") + sys.stdout.flush() if stderr: sys.stderr.write(stderr.decode("utf-8") + "\n") sys.stderr.flush() diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/Inputs/clang-tidy-diff/test.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/Inputs/clang-tidy-diff/test.cpp new file mode 100644 index 0000000000000..63fe1d0109392 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/infrastructure/Inputs/clang-tidy-diff/test.cpp @@ -0,0 +1 @@ +int add(int a, int b) { return PLACEHOLDER; } diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-diff.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-diff.cpp index 43b7d781e6a7a..63fe155df7817 100644 --- a/clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-diff.cpp +++ b/clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-diff.cpp @@ -9,6 +9,14 @@ // RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff -checks=-*,modernize-use-override -j 1 -- -std=c++11 2>&1 | FileCheck %s --check-prefix=CHECK-J1 // CHECK-J1: Running clang-tidy in 1 threads... + +// Test that running over multiple files don't produce blank lines in output +// RUN: not diff -U0 %s %t.cpp > %t.diff +// RUN: sed 's/PLACEHOLDER/a + b + 0/' %S/Inputs/clang-tidy-diff/test.cpp > %t.clean.cpp +// RUN: not diff -U0 %S/Inputs/clang-tidy-diff/test.cpp %t.clean.cpp > %t.clean.diff +// RUN: cat %t.clean.diff %t.diff | %clang_tidy_diff -checks=-*,modernize-use-override -j 1 -- -std=c++11 2>&1 | FileCheck %s --check-prefix=CHECK-NOBLANK +// CHECK-NOBLANK: Running clang-tidy in 1 threads... +// CHECK-NOBLANK-NEXT: :8: warning: annotate this struct A { virtual void f() {} virtual void g() {} `````````` </details> https://github.com/llvm/llvm-project/pull/213873 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
