andrej@1820: #!/bin/sh andrej@1820: andrej@2436: andrej@2436: andrej@2435: cleanup() andrej@2435: { andrej@2436: find $PYTEST_DIR -name '*.pyc' -delete andrej@2435: } andrej@2435: andrej@1820: andrej@2435: andrej@2436: print_help() andrej@2436: { andrej@2436: echo "Usage: run_python_tests.sh [--on-local-xserver]" andrej@2436: echo "" andrej@2436: echo "--on-local-xserver" andrej@2436: echo " all tests are run on local X-server. " andrej@2436: echo " User can see test in action." andrej@2436: echo " Any interaction (mouse, keyboard) should be avoided" andrej@2436: echo " By default without arguments script runs pytest on virtual X serverf." andrej@2436: echo "" andrej@2435: andrej@2436: exit 1 andrej@2436: } andrej@1820: andrej@2436: main() andrej@2436: { andrej@2436: LC_ALL=ru_RU.utf-8 andrej@2436: PYTEST_DIR=./tests/tools andrej@2436: andrej@2436: if [ ! -d $PYTEST_DIR ]; then andrej@2436: echo "Script should be run from top directory in repository" andrej@2436: exit 1; andrej@2436: fi andrej@2436: andrej@2436: use_xvfb=0 andrej@2436: if [ "$1" != "--on-local-xserver" ]; then andrej@2436: export DISPLAY=:42 andrej@2436: use_xvfb=1 andrej@2436: Xvfb $DISPLAY -screen 0 1280x1024x24 & andrej@2436: sleep 1 andrej@2436: fi andrej@2435: andrej@2435: andrej@2436: cleanup andrej@1820: andrej@2436: ret=0 andrej@2436: DELAY=400 andrej@2436: KILL_DELAY=$(($DELAY + 30)) andrej@2436: timeout -k $KILL_DELAY $DELAY pytest --timeout=10 ./tests/tools andrej@2436: ret=$? andrej@2436: andrej@2436: cleanup andrej@2436: andrej@2436: [ $use_xvfb = 1 ] && pkill -9 Xvfb andrej@2436: exit $ret andrej@2436: } andrej@2436: andrej@2436: andrej@2436: [ "$1" = "--help" -o "$1" = "-h" ] && print_help andrej@2436: main $@