2 . util/travis/common.sh
4 needs_compile || exit 0
6 function perform_lint() {
7 echo "Performing LINT..."
8 CLANG_FORMAT=clang-format-3.9
9 CLANG_FORMAT_WHITELIST="util/travis/clang-format-whitelist.txt"
11 if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then
12 # Get list of every file modified in this pull request
13 files_to_lint="$(git diff --name-only --diff-filter=ACMRTUXB $TRAVIS_COMMIT_RANGE | grep '^src/[^.]*[.]\(cpp\|h\)$' | egrep -v '^src/(gmp|lua|jsoncpp)/' || true)"
15 # Check everything for branch pushes
16 files_to_lint="$(find src/ -name '*.cpp' -or -name '*.h' | egrep -v '^src/(gmp|lua|jsoncpp)/')"
21 for f in ${files_to_lint}; do
22 d=$(diff -u "$f" <(${CLANG_FORMAT} "$f") || true)
24 if ! [ -z "$d" ]; then
25 errorcount=$((errorcount+1))
27 printf "The file %s is not compliant with the coding style" "$f"
28 if [ ${errorcount} -gt 50 ]; then
29 printf "\nToo many errors encountered previously, this diff is hidden.\n"
34 whitelisted=$(egrep -c "^${f}" "${CLANG_FORMAT_WHITELIST}")
36 # If file is not whitelisted, mark a failure
37 if [ ${whitelisted} -eq 0 ]; then
43 if [ "$fail" = 1 ]; then
44 echo "LINT reports failure."
51 if [[ "$LINT" == "1" ]]; then
57 if [[ $PLATFORM == "Unix" ]]; then
59 cd travisbuild || exit 1
62 if [[ $COMPILER == "g++-6" ]]; then
67 # Clang builds with FreeType fail on Travis
68 if [[ $CC == "clang" ]]; then
69 CMAKE_FLAGS+=' -DENABLE_FREETYPE=FALSE'
72 if [[ $TRAVIS_OS_NAME == "osx" ]]; then
73 CMAKE_FLAGS+=' -DCUSTOM_GETTEXT_PATH=/usr/local/opt/gettext'
76 cmake -DCMAKE_BUILD_TYPE=Debug \
78 -DENABLE_GETTEXT=TRUE \
83 echo "Running unit tests."
84 CMD="../bin/minetest --run-unittests"
85 if [[ "$VALGRIND" == "1" ]]; then
86 valgrind --leak-check=full --leak-check-heuristics=all --undef-value-errors=no --error-exitcode=9 ${CMD} && exit 0
91 elif [[ $PLATFORM == Win* ]]; then
92 [[ $CC == "clang" ]] && exit 1 # Not supposed to happen
93 # We need to have our build directory outside of the minetest directory because
94 # CMake will otherwise get very very confused with symlinks and complain that
95 # something is not a subdirectory of something even if it actually is.
97 # /home/travis/minetest/minetest/travisbuild/minetest
99 # /home/travis/minetest/minetest/travisbuild/minetest/travisbuild/minetest
101 # /home/travis/minetest/minetest/travisbuild/minetest/travisbuild/minetest/travisbuild/minetest
105 export EXISTING_MINETEST_DIR=$OLDDIR
106 export NO_MINETEST_GAME=1
107 if [[ $PLATFORM == "Win32" ]]; then
108 "$OLDDIR/util/buildbot/buildwin32.sh" travisbuild && exit 0
109 elif [[ $PLATFORM == "Win64" ]]; then
110 "$OLDDIR/util/buildbot/buildwin64.sh" travisbuild && exit 0
113 echo "Unknown platform \"${PLATFORM}\"."