tests/tools/run_python_tests.sh
branchwxPython4
changeset 3438 24fbd4d1fe80
parent 3437 ce366d67a5b7
child 3442 29dbdb09da2e
equal deleted inserted replaced
3437:ce366d67a5b7 3438:24fbd4d1fe80
     1 #!/bin/sh
       
     2 
       
     3 
       
     4 
       
     5 cleanup()
       
     6 {
       
     7     find $PYTEST_DIR -name '*.pyc' -delete
       
     8 }
       
     9 
       
    10 
       
    11 
       
    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 ""
       
    22 
       
    23     exit 1
       
    24 }
       
    25 
       
    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
       
    43 
       
    44 
       
    45     cleanup
       
    46 
       
    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 $@