[clang-tools-extra] [clang-tidy] support expect no diagnosis test (PR #91293)

Julian Schmidt via cfe-commits cfe-commits at lists.llvm.org
Fri May 10 04:16:26 PDT 2024


================
@@ -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


More information about the cfe-commits mailing list