]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CI: clang-tidy all headers
authorTimo Heister <timo.heister@gmail.com>
Mon, 27 Apr 2020 15:03:58 +0000 (11:03 -0400)
committerTimo Heister <timo.heister@gmail.com>
Wed, 29 Apr 2020 00:59:52 +0000 (20:59 -0400)
Hijack the already existing dummy.cc to include a dynamically created
header that includes all deal.II header files. This will run clang-tidy
on all headers.
I tried running clang-tidy on a .cc generated inside the build
directory, but this doesn't work for some reason.

closes #9933

contrib/utilities/run_clang_tidy.sh
source/dummy.cc

index 667bba5a86f50d9bb870196e07b189fe52c8a03c..f8fb8bb397efbcdefb8108f13dfb1c016a687501 100755 (executable)
@@ -57,13 +57,21 @@ CC=clang CXX=clang++ cmake "${ARGS[@]}" "$SRC" || (echo "cmake failed!"; false)
 
 cmake --build . --target expand_all_instantiations || (echo "make expand_all_instantiations failed!"; false) || exit 3
 
-# finally run it:
+# generate allheaders.h
+(cd include; find . -name '*.h'; cd $SRC/include/; find . -name '*.h') | grep -v allheaders.h | grep -v undefine_macros.h | sed 's|^./|#include <|' | sed 's|$|>|' >include/deal.II/allheaders.h
+
+# finally run it clang-tidy on deal.II
+#
 # pipe away stderr (just contains nonsensical "x warnings generated")
 # pipe output to output.txt
-run-clang-tidy.py -p . -quiet -header-filter="$SRC/include/*" 2>error.txt >output.txt
+run-clang-tidy.py -p . -quiet -header-filter "$SRC/include/*" -extra-arg='-DCLANG_TIDY' 2>error.txt >output.txt
+
+# grep interesting errors and make sure we remove duplicates:
+grep -E '(warning|error): ' output.txt output2.txt | sort | uniq >clang-tidy.log
 
-if grep -E -q '(warning|error): ' output.txt; then
-    grep -E '(warning|error): ' output.txt
+# if we have errors, report them and set exit status to failure
+if [ -s clang-tidy.log ]; then
+    cat clang-tidy.log
     exit 4
 fi
 
index 4f56c4fc0b8014c0ddcb2a74ef087ab35e3cbb31..20c308a63a4d4b2de5177c912bbbf774b8dfeb9d 100644 (file)
@@ -26,3 +26,12 @@ use_global_symbol_42()
 {
   (void)global_symbol_42;
 }
+
+/**
+ * If we are running the contrib/utilities/run_clang_tidy.sh script, we
+ * generate a header file allheaders.h that includes all deal.II
+ * headers. Include the file here so that all headers are being checked.
+ */
+#ifdef CLANG_TIDY
+#  include <deal.II/allheaders.h>
+#endif

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.