From 0d5d3bc9b8359c1a871e6449ef8dae060e16c543 Mon Sep 17 00:00:00 2001 From: "Juergen E. Fischer" Date: Thu, 3 Dec 2015 20:49:14 +0100 Subject: [PATCH] travis: add indentation check after running tests --- ci/travis/linux/after_script.sh | 2 +- ci/travis/linux/before_install.sh | 4 ++ ci/travis/linux/install.sh | 1 + scripts/verify-indentation.sh | 72 +++++++++++++++++++++++++++++++ tests/CMakeLists.txt | 4 ++ 5 files changed, 82 insertions(+), 1 deletion(-) create mode 100755 scripts/verify-indentation.sh diff --git a/ci/travis/linux/after_script.sh b/ci/travis/linux/after_script.sh index b377391551c..81864acfeb6 100755 --- a/ci/travis/linux/after_script.sh +++ b/ci/travis/linux/after_script.sh @@ -1 +1 @@ -cat '/tmp/ctest-important.log' +[ -r /tmp/ctest-important.log ] && cat /tmp/ctest-important.log diff --git a/ci/travis/linux/before_install.sh b/ci/travis/linux/before_install.sh index fd64f9db214..77424f3722e 100755 --- a/ci/travis/linux/before_install.sh +++ b/ci/travis/linux/before_install.sh @@ -56,8 +56,12 @@ sudo apt-get install --force-yes --no-install-recommends --no-install-suggests \ xfonts-base \ xfonts-scalable \ xvfb \ + python-pip \ + flip \ postgresql-9.1-postgis-2.1/precise # from ubuntugis-unstable, not pgdg +sudo -H pip install autopep8 # TODO when switching to trusty or above: replace python-pip with python-autopep8 + #update clang sudo apt-get install --force-yes llvm-3.7 llvm-3.7-dev clang-3.7 libstdc++-4.9-dev export CXX="clang++-3.7" diff --git a/ci/travis/linux/install.sh b/ci/travis/linux/install.sh index c28e2e2fc53..51f2f3b32d2 100755 --- a/ci/travis/linux/install.sh +++ b/ci/travis/linux/install.sh @@ -10,6 +10,7 @@ cmake -DWITH_SERVER=ON \ -DENABLE_PGTEST=ON \ -DWITH_QWTPOLAR=OFF \ -DWITH_APIDOC=ON \ + -DWITH_ASTYLE=ON \ -DWITH_PYSPATIALITE=ON \ -DGRASS_PREFIX7=/usr/lib/grass70 \ -DGRASS_INCLUDE_DIR7=/usr/lib/grass70/include .. diff --git a/scripts/verify-indentation.sh b/scripts/verify-indentation.sh new file mode 100755 index 00000000000..f927bf8a146 --- /dev/null +++ b/scripts/verify-indentation.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +cd $(git rev-parse --show-toplevel) + +export PATH=$PATH:$PWD/scripts + +if [ -z "$TRAVIS_COMMIT_RANGE" ]; then + echo "No commit range given" + exit 0 +fi + +TRAVIS_COMMIT_RANGE=${TRAVIS_COMMIT_RANGE/.../..} + +if ! type -p astyle.sh >/dev/null; then + echo astyle.sh not found + exit 1 +fi + +set -e + +ASTYLEDIFF=/tmp/astyle.diff +>$ASTYLEDIFF + +echo "Checking indentation in $TRAVIS_COMMIT_RANGE" +echo "Checking indentation in $TRAVIS_COMMIT_RANGE" >>/tmp/ctest-important.log +git log $TRAVIS_COMMIT_RANGE >>/tmp/ctest-important.log 2>&1 +git diff --name-only $TRAVIS_COMMIT_RANGE >>/tmp/ctest-important.log 2>&1 + +git diff --name-only $TRAVIS_COMMIT_RANGE | while read f +do + echo "Checking $f" >>/tmp/ctest-important.log + case "$f" in + src/core/gps/qextserialport/*|src/plugins/dxf2shp_converter/dxflib/src/*|src/plugins/globe/osgEarthQt/*|src/plugins/globe/osgEarthUtil/*) + echo $f skipped + continue + ;; + + *.cpp|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H|*.sip|*.py) + ;; + + *) + continue + ;; + esac + + m=$f.prepare + cp "$f" "$m" + astyle.sh "$f" + if diff -u "$m" "$f" >>$ASTYLEDIFF; then + rm $m + else + echo "File $f needs indentation" + fi +done + +if [ -s "$ASTYLEDIFF" ]; then + echo + echo "Required indentation updates:" + cat "$ASTYLEDIFF" + + cat <