From 8d8d1f984e9b058da00aa00ca65d9094fc726158 Mon Sep 17 00:00:00 2001
From: Luca Heltai <luca.heltai@sissa.it>
Date: Mon, 25 Aug 2014 16:06:01 +0200
Subject: [PATCH] Only test indentation on pull requests.

---
 .travis.yml                     |  1 +
 contrib/utilities/run_travis.sh | 37 ++++++++++++++++++++-------------
 2 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 8e6ed60f59..f8ba47b8ea 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,6 +22,7 @@ env:
 
 #  These tests run ok, but they might be out of policy...
   - CI_TEST_SUITE=build CI_BUILD_TYPE=Debug
+  - CI_TEST_SUITE=indent
 #  - CI_TEST_SUITE=build CI_BUILD_TYPE=Release
 
 # These tests only compile and run "make tests"
diff --git a/contrib/utilities/run_travis.sh b/contrib/utilities/run_travis.sh
index 651dc1b1d7..5d9ac76215 100755
--- a/contrib/utilities/run_travis.sh
+++ b/contrib/utilities/run_travis.sh
@@ -1,21 +1,30 @@
 #!/bin/sh
 case $1 in
-#mini)
-#    echo "Building and running mini tests in $2 mode."
-#    mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=$2 ../ && make -j4 && make tests
-#    ;;
 build)
-    echo "Running build tests."
-    mkdir build_test 
-    cd build_test
-    ctest -DCMAKE_BUILD_TYPE=$2 -V -j4 -S ../tests/run_buildtest.cmake
+    if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then 
+	echo "Running build tests."
+	mkdir build_test 
+	cd build_test
+	ctest -DCMAKE_BUILD_TYPE=$2 -V -j4 -S ../tests/run_buildtest.cmake
+    else 
+	echo "Build test is only run when merging to master branch. Exiting."
+    fi
     ;;
-#tests)
-#    echo "Running full testsuite."
-#    mkdir full_tests
-#    cd full_tests
-#    ctest -DCMAKE_BUILD_TYPE=$2 -V -j4 -S ../tests/run_testsuite.cmake
-#    ;;
+indent)
+     if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then 
+	echo "Running indentation test on master merge."
+     else 
+        echo "Running indentation test on Pull Request #${TRAVIS_PULL_REQUEST}"
+     fi
+     wget http://downloads.sourceforge.net/project/astyle/astyle/astyle%202.04/astyle_2.04_linux.tar.gz > /dev/null
+     tar xvfz astyle_2.04_linux.tar.gz > /dev/null
+     pushd astyle/build/gcc
+     make -j4 > /dev/null
+     popd
+     export PATH=`pwd`/astyle/build/gcc/bin:$PATH
+     ./contrib/utilities/indent
+     git diff-files --quiet || (git diff && failing_missing_command)	
+     ;;
 *)
     echo "Unrecognized test type! [$1]"
     exit 1
-- 
2.39.5