Skip to content

Commit d245519

Browse files
committed
fix: Run clang-tidy on headers as well (and in parallel)
1 parent 77c4926 commit d245519

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

devel-tools/run_clang_tidy.sh

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,17 @@ COLVARS_SOURCE_DIR="$TOPDIR/src"
2323
# Find all source files that are required to build the run_colvars_test
2424
COLVARS_STUB_SOURCE_DIR="$TOPDIR/misc_interfaces/stubs"
2525
COLVARS_TEST_SOURCE_DIR="$TOPDIR/tests/functional/"
26-
COLVARS_SOURCE_FILES=$(find $COLVARS_STUB_SOURCE_DIR $COLVARS_TEST_SOURCE_DIR $COLVARS_SOURCE_DIR -name "*.cpp")
27-
28-
num_test_failed=0
29-
all_output=""
30-
# Run clang-tidy over all files and save the results
31-
for colvars_src_file in $COLVARS_SOURCE_FILES; do
32-
clang_tidy_command="$CLANG_TIDY_BINARY -p=$COLVARS_BUILD_DIR --warnings-as-errors='*' $colvars_src_file"
33-
echo "Running $clang_tidy_command"
34-
output="$(eval $clang_tidy_command 2>&1)" || exit_code=$?
35-
all_output+="$output"
36-
if [[ $exit_code -gt 0 ]]; then
37-
num_test_failed=`expr $num_test_failed + 1`
38-
fi
39-
done
40-
41-
if [[ $num_test_failed -gt 0 ]]; then
42-
echo "There are $num_test_failed test(s) failed."
43-
echo "$all_output"
44-
exit 1
45-
else
46-
exit 0
26+
COLVARS_SOURCE_FILES=($(find $COLVARS_STUB_SOURCE_DIR $COLVARS_TEST_SOURCE_DIR $COLVARS_SOURCE_DIR -name "*.cpp"))
27+
28+
printf '%s\n' ${COLVARS_SOURCE_FILES[@]} | \
29+
xargs -I{} -P $(nproc) \
30+
bash -c "$CLANG_TIDY_BINARY -p=$COLVARS_BUILD_DIR -header-filter=.* --warnings-as-errors='*' '{}' > '{}'.log"
31+
32+
retcode=$?
33+
34+
if [ $retcode != 0 ] ; then
35+
cat "${COLVARS_SOURCE_FILES[@]/%/.log}"
36+
exit $retcode
4737
fi
38+
39+
exit 0

0 commit comments

Comments
 (0)