tests/tools/run_python_tests.sh
changeset 2436 82bfc75bcd9d
parent 2435 925adaa2cd5c
equal deleted inserted replaced
2435:925adaa2cd5c 2436:82bfc75bcd9d
     1 #!/bin/sh
     1 #!/bin/sh
       
     2 
       
     3 
     2 
     4 
     3 cleanup()
     5 cleanup()
     4 {
     6 {
     5     find ./tests/tools -name '*.pyc' -delete
     7     find $PYTEST_DIR -name '*.pyc' -delete
     6 }
     8 }
     7 
     9 
     8 LC_ALL=ru_RU.utf-8
       
     9 
       
    10 export DISPLAY=:42
       
    11 Xvfb $DISPLAY -screen 0 1280x1024x24 &
       
    12 sleep 1
       
    13 
    10 
    14 
    11 
    15 cleanup
    12 print_help()
       
    13 {
       
    14     echo "Usage: run_python_tests.sh [--on-local-xserver]"
       
    15     echo ""
       
    16     echo "--on-local-xserver"
       
    17     echo "                all tests are run on local X-server. "
       
    18     echo "                User can see test in action."
       
    19     echo "                Any interaction (mouse, keyboard) should be avoided"
       
    20     echo "                By default without arguments script runs pytest on virtual X serverf."
       
    21     echo ""
    16 
    22 
    17 ret=0
    23     exit 1
    18 DELAY=400
    24 }
    19 KILL_DELAY=$(($DELAY + 30))
       
    20 timeout -k $KILL_DELAY $DELAY pytest --timeout=10 ./tests/tools
       
    21 ret=$?
       
    22 
    25 
    23 cleanup
    26 main()
       
    27 {
       
    28     LC_ALL=ru_RU.utf-8
       
    29     PYTEST_DIR=./tests/tools
       
    30 
       
    31     if [ ! -d $PYTEST_DIR ]; then
       
    32 	echo "Script should be run from top directory in repository"
       
    33 	exit 1;
       
    34     fi
       
    35 
       
    36     use_xvfb=0
       
    37     if [ "$1" != "--on-local-xserver" ]; then
       
    38 	export DISPLAY=:42
       
    39 	use_xvfb=1
       
    40 	Xvfb $DISPLAY -screen 0 1280x1024x24 &
       
    41 	sleep 1
       
    42     fi
    24 
    43 
    25 
    44 
    26 pkill -9 Xvfb
    45     cleanup
    27 
    46 
    28 exit $ret
    47     ret=0
       
    48     DELAY=400
       
    49     KILL_DELAY=$(($DELAY + 30))
       
    50     timeout -k $KILL_DELAY $DELAY pytest --timeout=10 ./tests/tools
       
    51     ret=$?
       
    52 
       
    53     cleanup
       
    54 
       
    55     [ $use_xvfb = 1 ] && pkill -9 Xvfb
       
    56     exit $ret
       
    57 }
       
    58 
       
    59 
       
    60 [ "$1" = "--help" -o "$1" = "-h" ] && print_help
       
    61 main $@