From 612b421254769c9bf95271f1d1f7458f6c7dc9b9 Mon Sep 17 00:00:00 2001
From: Roman Tsisyk <roman@tsisyk.com>
Date: Thu, 9 Jun 2016 15:56:27 +0300
Subject: [PATCH] Travis CI: split tests and coverage analysis

Move coverage scripts to tarantool/build
---
 .build.mk                   | 31 +++++++++++++++++++++++++++++++
 .gitignore                  |  1 +
 .travis.yml                 |  8 +++++++-
 extra/travis/build_linux.sh | 37 -------------------------------------
 extra/travis/build_osx.sh   |  8 --------
 test.sh                     |  1 -
 6 files changed, 39 insertions(+), 47 deletions(-)
 create mode 100644 .build.mk
 delete mode 100755 extra/travis/build_linux.sh
 delete mode 100755 extra/travis/build_osx.sh
 delete mode 100644 test.sh

diff --git a/.build.mk b/.build.mk
new file mode 100644
index 0000000000..b10ef10c4e
--- /dev/null
+++ b/.build.mk
@@ -0,0 +1,31 @@
+#
+# Travis rules
+#
+
+travis_deps_linux:
+	sudo apt-get update > /dev/null
+	sudo apt-get -q -y install binutils-dev python-daemon python-yaml
+	sudo pip install six==1.9.0
+	sudo pip install gevent
+
+travis_test_linux: travis_deps_linux
+	cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo
+	make -j8
+	cd test && /usr/bin/python test-run.py
+
+travis_coverage: travis_deps_linux
+	cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_GCOV=ON
+	make -j8
+	# Enable --long tests for coverage
+	cd test && /usr/bin/python test-run.py --long
+
+travis_deps_osx:
+	brew install openssl
+	sudo pip install python-daemon PyYAML
+	sudo pip install six==1.9.0
+	sudo pip install gevent
+
+travis_test_osx: travis_deps_osx
+	cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo
+	make -j8
+	cd test && python test-run.py
diff --git a/.gitignore b/.gitignore
index 0ce8ccf383..87a97d8100 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@ _CPack_Packages
 *.gcno
 *.gcda
 *.gcov
+coverage/
 coverage.info
 *.o
 *.reject
diff --git a/.travis.yml b/.travis.yml
index ffab6c7af8..11de166faf 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,8 @@ compiler:
 
 env:
     matrix:
+      - PACK=none
+      - PACK=coverage
       - OS=el DIST=6 PACK=rpm
       - OS=el DIST=7 PACK=rpm
       - OS=fedora DIST=22 PACK=rpm
@@ -26,10 +28,10 @@ env:
       - OS=debian DIST=wheezy PACK=deb
       - OS=debian DIST=stretch PACK=deb
       - OS=debian DIST=sid PACK=deb
-      - PACK=none
 
 matrix:
     allow_failures:
+      - env: PACK=coverage
       - env: OS=el DIST=6 PACK=rpm
       - env: OS=el DIST=7 PACK=rpm
       - env: OS=fedora DIST=22 PACK=rpm
@@ -45,6 +47,8 @@ matrix:
       - env: OS=debian DIST=sid PACK=deb
 
     exclude:
+      - env: PACK=coverage
+        compiler: clang
       - env: OS=el DIST=6 PACK=rpm
         compiler: clang
       - env: OS=el DIST=7 PACK=rpm
@@ -71,6 +75,8 @@ matrix:
         compiler: clang
       - env: OS=debian DIST=sid PACK=deb
         compiler: clang
+      - env: PACK=coverage
+        os: osx
       - env: OS=el DIST=6 PACK=rpm
         os: osx
       - env: OS=el DIST=7 PACK=rpm
diff --git a/extra/travis/build_linux.sh b/extra/travis/build_linux.sh
deleted file mode 100755
index 9ada142ef1..0000000000
--- a/extra/travis/build_linux.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-sudo apt-get update > /dev/null
-sudo apt-get -q -y install binutils-dev python-daemon python-yaml
-sudo apt-get -q -y install libmysqlclient-dev libpq-dev postgresql-server-dev-all
-sudo pip install six==1.9.0
-sudo pip install gevent
-sudo pip install geventconnpool
-CMAKE_OPTS=""
-if [ -n "${COVERALLS_TOKEN}" ] && [ "${CC}" = "gcc" ]; then
-    echo "Code coverage analysis is enabled"
-    sudo apt-get -q -y install lcov
-    gem install coveralls-lcov
-    CMAKE_OPTS="-DENABLE_GCOV=ON"
-else
-    COVERALLS_TOKEN=""
-fi
-cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo ${CMAKE_OPTS}
-make -j8
-
-cd test
-/usr/bin/python test-run.py
-[ $? -eq 0 ] || exit $?
-cd ..
-
-if [ -n "${COVERALLS_TOKEN}" ]; then
-    echo "Collecting code coverage information"
-    # http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/
-    LCOV_FILE="$(pwd)/coverage.info"
-    # Capture coverage info
-    lcov --directory src/ --capture --output-file ${LCOV_FILE}.tmp
-    # Filter out system, test and third-party code
-    lcov --remove ${LCOV_FILE}.tmp 'tests/*' 'third_party/*' '/usr/*' \
-        --output-file ${LCOV_FILE}
-    rm -f ${LCOV_FILE}.tmp
-    echo "Exporting code coverage information to coveralls.io"
-    # Upload to coveralls.io
-    coveralls-lcov --repo-token ${COVERALLS_TOKEN} ${LCOV_FILE}
-fi
diff --git a/extra/travis/build_osx.sh b/extra/travis/build_osx.sh
deleted file mode 100755
index 2826fbddf5..0000000000
--- a/extra/travis/build_osx.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-brew install openssl
-sudo pip install python-daemon PyYAML
-sudo pip install six==1.9.0
-sudo pip install gevent
-sudo pip install geventconnpool
-cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo
-make -j8
-cd test && python test-run.py
diff --git a/test.sh b/test.sh
deleted file mode 100644
index 66947e6335..0000000000
--- a/test.sh
+++ /dev/null
@@ -1 +0,0 @@
-bash ./extra/travis/build_$TRAVIS_OS_NAME.sh
-- 
GitLab