# HG changeset patch
# User Andrey Skvortsov <andrej.skvortzov@gmail.com>
# Date 1505586377 -10800
# Node ID 76f5eba31afd4486503c40d2e50600eb61b5af02
# Parent  27976d1606a401538b3f14b730ec40cad1ca54f5
add shell script to run all python tests and automatically handle Xvfb

diff -r 27976d1606a4 -r 76f5eba31afd bitbucket-pipelines.yml
--- a/bitbucket-pipelines.yml	Sat Sep 16 21:24:22 2017 +0300
+++ b/bitbucket-pipelines.yml	Sat Sep 16 21:26:17 2017 +0300
@@ -7,16 +7,13 @@
             script: # Modify the commands below to build your repository.
               - /usr/bin/python --version
               - ./tests/tools/check_source.sh
-              - Xvfb :42 -screen 0 1280x1024x24 &
-              - DISPLAY=:42 pytest --timeout=10 ./tests/tools
-              - pkill -9 Xvfb
+              - ./tests/tools/run_python_tests.sh
+
 
   default:
     - step:
         script: # Modify the commands below to build your repository.
           - /usr/bin/python --version
-          - ./tests/tools/check_source.sh
-          - Xvfb :42 -screen 0 1280x1024x24 &
-          - DISPLAY=:42 pytest --timeout=10 ./tests/tools
-          - pkill -9 Xvfb
+          - ./tests/tools/check_source.sh 
+          - ./tests/tools/run_python_tests.sh         
           
diff -r 27976d1606a4 -r 76f5eba31afd tests/tools/run_python_tests.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/tools/run_python_tests.sh	Sat Sep 16 21:26:17 2017 +0300
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+
+export DISPLAY=:42
+Xvfb $DISPLAY -screen 0 1280x1024x24 &
+sleep 1
+
+ret=0
+DELAY=400
+KILL_DELAY=$(($DELAY + 30))
+timeout -k $KILL_DELAY $DELAY pytest --timeout=10 ./tests/tools
+ret=$?
+
+pkill -9 Xvfb
+
+exit $ret