[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
via cfe-commits
cfe-commits at lists.llvm.org
Mon May 6 19:56:55 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tools-extra
Author: Congcong Cai (HerrCai0907)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/91293.diff
3 Files Affected:
- (modified) clang-tools-extra/test/clang-tidy/check_clang_tidy.py (+11-2)
- (added) clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hpp (+6)
- (removed) clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hxx (-6)
``````````diff
diff --git a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
index 6d4b466afa691a..d1cfe086fc968c 100755
--- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -99,6 +99,7 @@ def __init__(self, args, extra_args):
self.has_check_fixes = False
self.has_check_messages = False
self.has_check_notes = False
+ self.expect_no_diagnosis = args.expect_no_diagnosis
self.export_fixes = args.export_fixes
self.fixes = MessagePrefix("CHECK-FIXES")
self.messages = MessagePrefix("CHECK-MESSAGES")
@@ -225,6 +226,11 @@ def run_clang_tidy(self):
print(diff_output)
print("------------------------------------------------------------------")
return clang_tidy_output
+
+ def check_no_diagnosis(self, clang_tidy_output):
+ print(clang_tidy_output)
+ if clang_tidy_output != "":
+ sys.exit('expect no diagnosis')
def check_fixes(self):
if self.has_check_fixes:
@@ -273,11 +279,13 @@ def check_notes(self, clang_tidy_output):
def run(self):
self.read_input()
- if self.export_fixes is None:
+ if self.export_fixes is None and not self.expect_no_diagnosis:
self.get_prefixes()
self.prepare_test_inputs()
clang_tidy_output = self.run_clang_tidy()
- if self.export_fixes is None:
+ if self.expect_no_diagnosis:
+ self.check_no_diagnosis(clang_tidy_output)
+ elif self.export_fixes is None:
self.check_fixes()
self.check_messages(clang_tidy_output)
self.check_notes(clang_tidy_output)
@@ -310,6 +318,7 @@ def parse_arguments():
formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument("-expect-clang-tidy-error", action="store_true")
+ parser.add_argument("-expect-no-diagnosis", action="store_true")
parser.add_argument("-resource-dir")
parser.add_argument("-assume-filename")
parser.add_argument("input_file_name")
diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hpp b/clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hpp
new file mode 100644
index 00000000000000..ce37877a22ecab
--- /dev/null
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hpp
@@ -0,0 +1,6 @@
+// RUN: %check_clang_tidy %s misc-unused-using-decls -expect-no-diagnosis %t
+
+// Verify that we don't generate the warnings on header files.
+namespace foo { class Foo {}; }
+
+using foo::Foo;
diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hxx b/clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hxx
deleted file mode 100644
index f15e4fae80c0bc..00000000000000
--- a/clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hxx
+++ /dev/null
@@ -1,6 +0,0 @@
-// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- --fix-notes -- -fno-delayed-template-parsing -isystem %S/Inputs
-
-// Verify that we don't generate the warnings on header files.
-namespace foo { class Foo {}; }
-
-using foo::Foo;
``````````
</details>
https://github.com/llvm/llvm-project/pull/91293
More information about the cfe-commits
mailing list