Skip to content

Commit

Permalink
iox-#2011 Fix nightly build
Browse files Browse the repository at this point in the history
  • Loading branch information
elBoberido committed Sep 29, 2023
1 parent 5a1c298 commit cac6f6c
Showing 1 changed file with 36 additions and 25 deletions.
61 changes: 36 additions & 25 deletions tools/scripts/clang_tidy_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fi

function scanWithFileList() {
FILE_WITH_SCAN_LIST=$1
FILE_TO_SCAN=$2
FILES_TO_SCAN=$2

if ! test -f "$FILE_WITH_SCAN_LIST"
then
Expand All @@ -81,34 +81,48 @@ function scanWithFileList() {
if [[ "$(echo $LINE | grep "#" | wc -l)" == "1" ]]; then
break
fi
FILE_LIST="${FILE_LIST} $LINE"
SCAN_LIST_ENTRIES="${SCAN_LIST_ENTRIES} $LINE"
done < "$FILE_WITH_SCAN_LIST"

if [[ -n $FILE_TO_SCAN ]]
if [[ -z $SCAN_LIST_ENTRIES ]]
then
if ! test -f "$FILE_TO_SCAN"
then
echo "The file which should be scanned '${FILE_TO_SCAN}' does not exist"
return 1
fi
echo "'${FILE_WITH_SCAN_LIST}' is empty skipping scan."
return 0
fi

if [[ $(find ${FILE_LIST} -type f | grep -E ${FILE_FILTER} | grep ${FILE_TO_SCAN} | wc -l) == "0" ]]
then
echo "Skipping file '${FILE_TO_SCAN}' since it is not part of '${FILE_WITH_SCAN_LIST}'"
return 0
fi
ALL_FILES_FROM_SCAN_LIST=$(find ${SCAN_LIST_ENTRIES} -type f | grep -E ${FILE_FILTER} | sort | uniq)

echo "Scanning file: ${FILE_TO_SCAN}"
$CLANG_TIDY_CMD --warnings-as-errors=* -p build $FILE_TO_SCAN
if [[ -n $FILES_TO_SCAN ]]
then
for FILE in $FILES_TO_SCAN; do
if $(echo ${ALL_FILES_FROM_SCAN_LIST} | tr " " '\n' | grep -q ${FILE})
then
FILES="${FILES} ${FILE}"
else
echo "Skipping file '${FILE}' since it is not part of '${FILE_WITH_SCAN_LIST}'"
fi
done
else
if [[ -z $FILE_LIST ]]
then
echo "'${FILE_WITH_SCAN_LIST}' is empty skipping folder scan."
return 0
fi
echo "Performing full scan of all folders in '${FILE_WITH_SCAN_LIST}'"
$CLANG_TIDY_CMD --warnings-as-errors=* -p build "$(find "${FILE_LIST}" -type f | grep -E ${FILE_FILTER})"
FILES=${ALL_FILES_FROM_SCAN_LIST}
fi

if [[ $FILES ]]
then
echo "Number of files to scan: $(echo "${FILES}" | grep -v "^$" | wc -l)"
for FILE in $FILES; do
if ! test -f "${FILE}"
then
echo "The file which should be scanned '${FILE}' does not exist"
return 1
else
echo "Scanning file: ${FILE}"
$CLANG_TIDY_CMD --warnings-as-errors=* --quiet -p build ${FILE}
fi
done
fi

return 0
}

if [[ "$MODE" == "hook"* ]]; then
Expand All @@ -126,10 +140,7 @@ if [[ "$MODE" == "hook"* ]]; then
else
echo " processing ..."
if [[ $FILE_WITH_SCAN_LIST ]]; then
for FILE_TO_SCAN in $FILES; do
echo " ${FILE_TO_SCAN}"
scanWithFileList $FILE_WITH_SCAN_LIST $FILE_TO_SCAN
done
scanWithFileList $FILE_WITH_SCAN_LIST $FILES
else
$CLANG_TIDY_CMD -p build $FILES
fi
Expand Down

0 comments on commit cac6f6c

Please sign in to comment.