File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,14 @@ matrix:
5757 # We have only one program and the variable $BUILDOPTIONS
5858 # has only the options to that program: testme.sh
5959
60+ # Check source code format
61+ - env : BUILDOPTIONS='--format'
62+ addons :
63+ apt :
64+ packages :
65+ - astyle
66+ sudo : required
67+
6068 # GCC for the 32-bit architecture (no valgrind yet)
6169 - env : BUILDOPTIONS='--with-cc=gcc --with-m32'
6270 addons :
Original file line number Diff line number Diff line change @@ -72,6 +72,10 @@ _help()
7272 echo " --all Choose all architectures and gcc and clang"
7373 echo " as compilers but does not run valgrind."
7474 echo
75+ echo " --format Runs the various source-code formatters"
76+ echo " and generators and checks if the sources"
77+ echo " are clean."
78+ echo
7579 echo " -h"
7680 echo " --help This message"
7781 echo
@@ -168,6 +172,7 @@ MTEST_RAND=""
168172VALGRIND_OPTS=" --leak-check=full --show-leak-kinds=all --error-exitcode=1 "
169173# VALGRIND_OPTS=""
170174VALGRIND_BIN=" "
175+ CHECK_FORMAT=" "
171176
172177alive_pid=0
173178
225230 --mtest-real-rand)
226231 MTEST_RAND=" -DLTM_MTEST_REAL_RAND"
227232 ;;
233+ --format)
234+ CHECK_FORMAT=" 1"
235+ ;;
228236 --all)
229237 COMPILERS=" gcc clang"
230238 ARCHFLAGS=" -m64 -m32 -mx32"
243251 shift
244252done
245253
254+ function _check_git() {
255+ git update-index --refresh > /dev/null || true
256+ git diff-index --quiet HEAD -- . || ( echo " FAILURE: $* " && exit 1 )
257+ }
258+
259+ if [[ " $CHECK_FORMAT " == " 1" ]]
260+ then
261+ make astyle
262+ _check_git " make astyle"
263+ make new_file
264+ _check_git " make format"
265+ perl helper.pl -a
266+ exit $?
267+ fi
268+
246269[[ " $VALGRIND_BIN " == " " ]] && VALGRIND_OPTS=" "
247270
248271# default to CC environment variable if no compiler is defined but some other options
You can’t perform that action at this time.
0 commit comments