Skip to content

Commit 179daef

Browse files
committed
add travis-build to check source-code format
1 parent 9e8b71e commit 179daef

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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:

testme.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff 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=""
168172
VALGRIND_OPTS=" --leak-check=full --show-leak-kinds=all --error-exitcode=1 "
169173
#VALGRIND_OPTS=""
170174
VALGRIND_BIN=""
175+
CHECK_FORMAT=""
171176

172177
alive_pid=0
173178

@@ -225,6 +230,9 @@ do
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"
@@ -243,6 +251,21 @@ do
243251
shift
244252
done
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

0 commit comments

Comments
 (0)