[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
https://github.com/HerrCai0907 closed https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
https://github.com/PiotrZSL approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
@@ -226,6 +236,10 @@ def run_clang_tidy(self): print("--") return clang_tidy_output +def check_no_diagnosis(self, clang_tidy_output): +if clang_tidy_output != "": +sys.exit("No diagnostics were expected, but found the ones above") HerrCai0907 wrote: Yes, It is a mistake. I forgot to delete the printing during development. https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
@@ -226,6 +236,10 @@ def run_clang_tidy(self): print("--") return clang_tidy_output +def check_no_diagnosis(self, clang_tidy_output): +if clang_tidy_output != "": +sys.exit("No diagnostics were expected, but found the ones above") 5chmidti wrote: Ah, ok. So the original printing that I pointed out was not intended to be there anyway. https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
@@ -226,6 +236,10 @@ def run_clang_tidy(self): print("--") return clang_tidy_output +def check_no_diagnosis(self, clang_tidy_output): +if clang_tidy_output != "": +sys.exit("No diagnostics were expected, but found the ones above") HerrCai0907 wrote: We don't need to print clang-tidy-output, it is already printed in https://github.com/llvm/llvm-project/pull/91293/files#diff-a05fb648cb6609a7ff1985264bfb61b73c3c226224ef0b40f3c72c9c8703daaeL213 https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
@@ -226,6 +236,10 @@ def run_clang_tidy(self): print("--") return clang_tidy_output +def check_no_diagnosis(self, clang_tidy_output): +if clang_tidy_output != "": +sys.exit("No diagnostics were expected, but found the ones above") 5chmidti wrote: You may have accidentally not staged the hunk with the `print`. Either way, what I meant was: ```python if clang_tidy_output != "": print(clang_tidy_output) sys.exit("No diagnostics were expected, but found the ones above") ``` Because we already check if `clang_tidy_output` is empty to potentially terminate because errors were found when they shouldn't have, we can call print inside the if, so we don't print an empty string. (-> nit). https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
https://github.com/HerrCai0907 updated https://github.com/llvm/llvm-project/pull/91293 >From 55aecbedf3e10207eaef1d4c7913086a32e16b1e Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Tue, 7 May 2024 10:55:45 +0800 Subject: [PATCH 1/5] [clang-tidy] support expect no diagnosis test --- .../test/clang-tidy/check_clang_tidy.py | 13 +++-- .../clang-tidy/checkers/misc/unused-using-decls.hpp | 6 ++ .../clang-tidy/checkers/misc/unused-using-decls.hxx | 6 -- 3 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hpp delete mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hxx 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 6d4b466afa691..d1cfe086fc968 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 0..ce37877a22eca --- /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 f15e4fae80c0b..0 --- 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; >From 2a5d18a739e56cbefbff40d49cc1546fcd4b82d4 Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Tue, 7 May 2024 13:32:29 +0800 Subject: [PATCH 2/5] format --- clang-tools-extra/test/clang-tidy/check_clang_tidy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 d1cfe086fc968..e87a53df29969 100755 --- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py +++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py @@ -226,11 +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') +sys.exit("expect no diagnosis") def check_fixes(self): if
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
@@ -226,6 +226,11 @@ def run_clang_tidy(self): print("--") return clang_tidy_output +def check_no_diagnosis(self, clang_tidy_output): +print(clang_tidy_output) +if clang_tidy_output != "": +sys.exit("No diagnostics were expected, but found the ones above") 5chmidti wrote: You can move the print inside the if-branch https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
@@ -172,12 +173,11 @@ def get_prefixes(self): ) if not has_check_fix and not has_check_message and not has_check_note: -sys.exit( -"%s, %s or %s not found in the input" -% (self.fixes.prefix, self.messages.prefix, self.notes.prefix) -) +self.expect_no_diagnosis = True -assert self.has_check_fixes or self.has_check_messages or self.has_check_notes +assert self.expect_no_diagnosis != ( +self.has_check_fixes or self.has_check_messages or self.has_check_notes +) 5chmidti wrote: What do you think about emitting a message instead of asserting? I.e., something using `sys.ext` like in the other cases that the script exits? https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
https://github.com/5chmidti approved this pull request. Overall LGTM, just two small nits. W.r.t flag or no flag: This seems to be so rarely used (judging from the single test file that needed modification), that not having the flag is fine IMO. A check writer doesn't have to know about this small test infra detail, and it's also not *that* surprising, that if there are no `CHECK` messages, none are expected. Similar to the `implicit check-not`. However, I think I'd be best to get @PiotrZSL's thoughts as well https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
https://github.com/HerrCai0907 updated https://github.com/llvm/llvm-project/pull/91293 >From 55aecbedf3e10207eaef1d4c7913086a32e16b1e Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Tue, 7 May 2024 10:55:45 +0800 Subject: [PATCH 1/4] [clang-tidy] support expect no diagnosis test --- .../test/clang-tidy/check_clang_tidy.py | 13 +++-- .../clang-tidy/checkers/misc/unused-using-decls.hpp | 6 ++ .../clang-tidy/checkers/misc/unused-using-decls.hxx | 6 -- 3 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hpp delete mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hxx 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 6d4b466afa691..d1cfe086fc968 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 0..ce37877a22eca --- /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 f15e4fae80c0b..0 --- 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; >From 2a5d18a739e56cbefbff40d49cc1546fcd4b82d4 Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Tue, 7 May 2024 13:32:29 +0800 Subject: [PATCH 2/4] format --- clang-tools-extra/test/clang-tidy/check_clang_tidy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 d1cfe086fc968..e87a53df29969 100755 --- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py +++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py @@ -226,11 +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') +sys.exit("expect no diagnosis") def check_fixes(self): if
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
@@ -226,6 +226,11 @@ def run_clang_tidy(self): 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") SimplyDanny wrote: ```suggestion print(clang_tidy_output) if clang_tidy_output != "": sys.exit("No diagnostics were expected, but found the ones above") ``` https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
https://github.com/SimplyDanny approved this pull request. I like this much more than an explicit option. However, consider my feedback as suggestions only as I don't have that much of experience with the project. I might miss or misinterpret something. https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
https://github.com/SimplyDanny edited https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
https://github.com/HerrCai0907 updated https://github.com/llvm/llvm-project/pull/91293 >From 55aecbedf3e10207eaef1d4c7913086a32e16b1e Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Tue, 7 May 2024 10:55:45 +0800 Subject: [PATCH 1/3] [clang-tidy] support expect no diagnosis test --- .../test/clang-tidy/check_clang_tidy.py | 13 +++-- .../clang-tidy/checkers/misc/unused-using-decls.hpp | 6 ++ .../clang-tidy/checkers/misc/unused-using-decls.hxx | 6 -- 3 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hpp delete mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hxx 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 6d4b466afa691..d1cfe086fc968 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 0..ce37877a22eca --- /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 f15e4fae80c0b..0 --- 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; >From 2a5d18a739e56cbefbff40d49cc1546fcd4b82d4 Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Tue, 7 May 2024 13:32:29 +0800 Subject: [PATCH 2/3] format --- clang-tools-extra/test/clang-tidy/check_clang_tidy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 d1cfe086fc968..e87a53df29969 100755 --- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py +++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py @@ -226,11 +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') +sys.exit("expect no diagnosis") def check_fixes(self): if
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
HerrCai0907 wrote: > And why is this not a valid test? No `CHECK-*` comments in the reference > file, so no violations from `clang-tidy` are expected? Because the FileCheck don't support empty input. https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
https://github.com/HerrCai0907 updated https://github.com/llvm/llvm-project/pull/91293 >From 55aecbedf3e10207eaef1d4c7913086a32e16b1e Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Tue, 7 May 2024 10:55:45 +0800 Subject: [PATCH 1/3] [clang-tidy] support expect no diagnosis test --- .../test/clang-tidy/check_clang_tidy.py | 13 +++-- .../clang-tidy/checkers/misc/unused-using-decls.hpp | 6 ++ .../clang-tidy/checkers/misc/unused-using-decls.hxx | 6 -- 3 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hpp delete mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hxx 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 6d4b466afa691..d1cfe086fc968 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 0..ce37877a22eca --- /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 f15e4fae80c0b..0 --- 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; >From 2a5d18a739e56cbefbff40d49cc1546fcd4b82d4 Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Tue, 7 May 2024 13:32:29 +0800 Subject: [PATCH 2/3] format --- clang-tools-extra/test/clang-tidy/check_clang_tidy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 d1cfe086fc968..e87a53df29969 100755 --- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py +++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py @@ -226,11 +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') +sys.exit("expect no diagnosis") def check_fixes(self): if
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
https://github.com/HerrCai0907 edited https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
HerrCai0907 wrote: I remove the command line option. Instead, when input don't have any check, check-clang-tidy will assume it should not diagnose anything. https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
https://github.com/HerrCai0907 updated https://github.com/llvm/llvm-project/pull/91293 >From 55aecbedf3e10207eaef1d4c7913086a32e16b1e Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Tue, 7 May 2024 10:55:45 +0800 Subject: [PATCH 1/3] [clang-tidy] support expect no diagnosis test --- .../test/clang-tidy/check_clang_tidy.py | 13 +++-- .../clang-tidy/checkers/misc/unused-using-decls.hpp | 6 ++ .../clang-tidy/checkers/misc/unused-using-decls.hxx | 6 -- 3 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hpp delete mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hxx 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 6d4b466afa691..d1cfe086fc968 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 0..ce37877a22eca --- /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 f15e4fae80c0b..0 --- 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; >From 2a5d18a739e56cbefbff40d49cc1546fcd4b82d4 Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Tue, 7 May 2024 13:32:29 +0800 Subject: [PATCH 2/3] format --- clang-tools-extra/test/clang-tidy/check_clang_tidy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 d1cfe086fc968..e87a53df29969 100755 --- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py +++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py @@ -226,11 +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') +sys.exit("expect no diagnosis") def check_fixes(self): if
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
SimplyDanny wrote: > If nothing is provided, then nothing can be detected. And why is this not a valid test? No `CHECK-*` comments in the reference file, so no violations from `clang-tidy` are expected? > `not` will treat non-zero return code as success. It is totally different > thing. https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
https://github.com/HerrCai0907 edited https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
https://github.com/HerrCai0907 edited https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
https://github.com/HerrCai0907 edited https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
HerrCai0907 wrote: > Why can the tests not just accept reference files that do not contain any > CHECK-* comments? run-clang-tidy do assert for this, since FileCheck need to use this information to check the result. If nothing is provided, then nothing can be detected. > Also, isn't there the // RUN: not %check_clang_tidy (note the not) command to > claim a test file doesn't trigger the specified checks? `not` will treat non-zero return code as success. It is totally different thing. https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
SimplyDanny wrote: Why can the tests not just accept reference files that do not contain any `CHECK-*` comments? Then, no separate argument would be needed. In fact, I still sometimes struggle to find the correct options, command line and `CHECK-*` syntax. More options further complicate the setup. Also, isn't there the `// RUN: not %check_clang_tidy` (note the `not`) command to claim a test file doesn't trigger the specified checks? https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
https://github.com/HerrCai0907 updated https://github.com/llvm/llvm-project/pull/91293 >From 55aecbedf3e10207eaef1d4c7913086a32e16b1e Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Tue, 7 May 2024 10:55:45 +0800 Subject: [PATCH 1/2] [clang-tidy] support expect no diagnosis test --- .../test/clang-tidy/check_clang_tidy.py | 13 +++-- .../clang-tidy/checkers/misc/unused-using-decls.hpp | 6 ++ .../clang-tidy/checkers/misc/unused-using-decls.hxx | 6 -- 3 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hpp delete mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hxx 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 00..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..00 --- 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; >From 2a5d18a739e56cbefbff40d49cc1546fcd4b82d4 Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Tue, 7 May 2024 13:32:29 +0800 Subject: [PATCH 2/2] format --- clang-tools-extra/test/clang-tidy/check_clang_tidy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 d1cfe086fc968c..e87a53df299695 100755 --- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py +++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py @@ -226,11 +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') +sys.exit("expect no diagnosis") def check_fixes(self): if
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r ddecadabebdd4b301bd65534b58009e57ac1bbe5...55aecbedf3e10207eaef1d4c7913086a32e16b1e clang-tools-extra/test/clang-tidy/check_clang_tidy.py `` View the diff from darker here. ``diff --- check_clang_tidy.py 2024-05-07 02:55:45.00 + +++ check_clang_tidy.py 2024-05-07 02:58:50.584570 + @@ -224,15 +224,15 @@ ) print("-- Fixes -") 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') +sys.exit("expect no diagnosis") def check_fixes(self): if self.has_check_fixes: try_run( [ `` https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
llvmbot wrote: @llvm/pr-subscribers-clang-tools-extra Author: Congcong Cai (HerrCai0907) Changes --- 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 00..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..00 --- 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; `` https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
llvmbot wrote: @llvm/pr-subscribers-clang-tidy Author: Congcong Cai (HerrCai0907) Changes --- 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 00..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..00 --- 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; `` https://github.com/llvm/llvm-project/pull/91293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)
https://github.com/HerrCai0907 created https://github.com/llvm/llvm-project/pull/91293 None >From 55aecbedf3e10207eaef1d4c7913086a32e16b1e Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Tue, 7 May 2024 10:55:45 +0800 Subject: [PATCH] [clang-tidy] support expect no diagnosis test --- .../test/clang-tidy/check_clang_tidy.py | 13 +++-- .../clang-tidy/checkers/misc/unused-using-decls.hpp | 6 ++ .../clang-tidy/checkers/misc/unused-using-decls.hxx | 6 -- 3 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hpp delete mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.hxx 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 00..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..00 --- 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; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits