]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
regress: Improve cppcheck-test
authorEric Bollengier <eric@baculasystems.com>
Mon, 11 Dec 2023 14:51:32 +0000 (15:51 +0100)
committerEric Bollengier <eric@baculasystems.com>
Tue, 13 Feb 2024 09:36:02 +0000 (10:36 +0100)
regress/tests/cppcheck-test

index 6d4e8fc8a9a487f26ffbec06751071ba02db713b..58f6fbf28c222cf9d512c2fcd247192b2709ae58 100755 (executable)
@@ -7,4 +7,18 @@
 # Run cppcheck
 #
 
-cppcheck --quiet --enable=all --std=c++11 --force --suppress=unreadVariable --suppress=cstyleCast --language=c++ ../bacula/src
+TARGET=$1
+
+if [ "$TARGET" == ALL ]; then
+    cppcheck --quiet --enable=all --std=c++11 --force --suppress=unreadVariable --suppress=cstyleCast --language=c++ ../bacula/src
+    exit $?
+fi
+
+if [ "$TARGET" != "" ]; then
+    cd ..
+    git diff-tree --no-commit-id --name-only -r ${TARGET}..HEAD > /tmp/file.list.$$
+    if grep -E c$ /tmp/file.list.$$ > /dev/null
+    then
+        grep -E '[ch]$' /tmp/file.list.$$ | xargs cppcheck --quiet --enable=all --std=c++11 --force --suppress=unreadVariable --suppress=cstyleCast --language=c++
+    fi
+fi