From df78cc3a48557311da4b56388db3cb019b4cfc44 Mon Sep 17 00:00:00 2001 From: Kamil Strzempowicz Date: Wed, 13 Sep 2017 23:38:19 +0200 Subject: [PATCH] Changes to the Travis CI Switch to old travis linux image to fix issue #169 Enable Xvfb driven examples execution on OSX Move Xvfb-related logic to functions in bash script --- .travis.yml | 11 ++++++++--- travis.sh | 55 +++++++++++++++++++++++++++++------------------------ 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/.travis.yml b/.travis.yml index 09486d34..45ddb055 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +group: deprecated-2017Q3 + language: cpp os: linux sudo: required @@ -6,9 +8,12 @@ compiler: - clang - gcc env: - - GMOCK_VER=1.8.0 - - GMOCK_VER=1.7.0 - - GMOCK_PATH=/usr/src/gmock #1.6.0 from ubuntu trusty repo + global: + - DISPLAY=:99 + matrix: + - GMOCK_VER=1.8.0 + - GMOCK_VER=1.7.0 + - GMOCK_PATH=/usr/src/gmock #1.6.0 from ubuntu trusty repo matrix: include: - os: linux diff --git a/travis.sh b/travis.sh index 7892eb93..423f31c9 100755 --- a/travis.sh +++ b/travis.sh @@ -2,6 +2,34 @@ set -e #break script on non-zero exitcode from any command set -x #display command being executed +startXvfb () { +# Xvfb sends SIGUSR1 to its parent when it finished startup, this causes the 'wait' below to stop waiting +# Starting Xvfb hangs on OSX, that's why we do this on Linux only now + if [[ "${TRAVIS_OS_NAME}" = "linux" ]]; then + trap : USR1 + (trap '' USR1; Xvfb $DISPLAY -screen 0 640x480x8 -nolisten tcp > /dev/null 2>&1) & + XVFBPID=$! + wait || : + trap '' USR1 + if ! kill -0 $XVFBPID 2> /dev/null; then + echo "Xvfb failed to start" >&2 + exit 1 + fi + else + sudo Xvfb $DISPLAY -screen 0 640x480x8 -nolisten tcp > /dev/null 2>&1 & + XVFBPID=$! + sleep 5 + fi +} + +killXvfb () { + if [ -n "${XVFBPID:-}" ]; then + # Stop virtual X display server + sudo kill $XVFBPID + wait + fi +} + CTEST_OUTPUT_ON_FAILURE=ON export CTEST_OUTPUT_ON_FAILURE @@ -27,26 +55,7 @@ cmake --build build cmake --build build --target test cmake --build build --target features -# Start virtual X display server - -# Starting Xvfb hangs on OSX, that's why we do this on Linux only now -if [ "${TRAVIS_OS_NAME}" = "linux" ]; then - DISPLAY=:99 - export DISPLAY - - # Xvfb sends SIGUSR1 to its parent when it finished startup, this causes the 'wait' below to stop waiting - trap : USR1 - (trap '' USR1; Xvfb $DISPLAY -screen 0 640x480x8 -nolisten tcp > /dev/null 2>&1) & - XVFBPID=$! - wait || : - trap '' USR1 - if ! kill -0 $XVFBPID 2> /dev/null; then - echo "Xvfb failed to start" >&2 - exit 1 - fi -else - unset DISPLAY -fi +startXvfb # Start virtual X display server for TEST in \ build/examples/Calc/GTestCalculatorSteps \ @@ -83,8 +92,4 @@ if [ -f "${TEST}" ]; then wait % fi -if [ -n "${XVFBPID:-}" ]; then - # Stop virtual X display server - kill $XVFBPID - wait -fi +killXvfb