Skip to content

Commit 0860a76

Browse files
szedergitster
authored andcommitted
travis-ci: fail if Coccinelle static analysis found something to transform
Coccinelle's and in turn 'make coccicheck's exit code only indicates that Coccinelle managed to finish its analysis without any errors (e.g. no unknown --options, no missing files, no syntax errors in the semantic patches, etc.), but it doesn't indicate whether it found any undesired code patterns to transform or not. To find out the latter, one has to look closer at 'make coccicheck's standard output and look for lines like: SPATCH result: contrib/coccinelle/<something>.cocci.patch And this only indicates that there is something to transform, but to see what the suggested transformations are one has to actually look into those '*.cocci.patch' files. This makes the automated static analysis build job on Travis CI not particularly useful, because it neither draws our attention to Coccinelle's findings, nor shows the actual findings. Consequently, new topics introducing undesired code patterns graduated to master on several occasions without anyone noticing. The only way to draw attention in such an automated setting is to fail the build job. Therefore, modify the 'ci/run-static-analysis.sh' build script to check all the resulting '*.cocci.patch' files, and fail the build job if any of them turns out to be not empty. Include those files' contents, i.e. Coccinelle's suggested transformations, in the build job's trace log, so we'll know why it failed. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 4ab8d1a commit 0860a76

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

ci/run-static-analysis.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,23 @@
77

88
make --jobs=2 coccicheck
99

10+
set +x
11+
12+
fail=
13+
for cocci_patch in contrib/coccinelle/*.patch
14+
do
15+
if test -s "$cocci_patch"
16+
then
17+
echo "$(tput setaf 1)Coccinelle suggests the following changes in '$cocci_patch':$(tput sgr0)"
18+
cat "$cocci_patch"
19+
fail=UnfortunatelyYes
20+
fi
21+
done
22+
23+
if test -n "$fail"
24+
then
25+
echo "$(tput setaf 1)error: Coccinelle suggested some changes$(tput sgr0)"
26+
exit 1
27+
fi
28+
1029
save_good_tree

0 commit comments

Comments
 (0)