tests/tools/run_python_tests.sh
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 05 Oct 2018 13:11:28 +0300
changeset 2435 925adaa2cd5c
parent 1825 bcb50e736a46
child 2436 82bfc75bcd9d
permissions -rwxr-xr-x
cleanup pyc files between running pytest

this is need to avoid problem sometimes tests are run inside docker
container and sometimes local.

Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/_pytest/config/__init__.py", line 409, in _importconftest
mod = conftestpath.pyimport()
File "/usr/lib/python2.7/dist-packages/py/_path/local.py", line 686, in pyimport
raise self.ImportMismatchError(modname, modfile, self)
ImportMismatchError: ('conftest', '/beremiz/tests/tools/conftest.py', local('/home/developer/beremiz/tests/tools/conftest.py'))
ERROR: could not load /home/developer/beremiz/tests/tools/conftest.py
1820
76f5eba31afd add shell script to run all python tests and automatically handle Xvfb
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     1
#!/bin/sh
76f5eba31afd add shell script to run all python tests and automatically handle Xvfb
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     2
2435
925adaa2cd5c cleanup pyc files between running pytest
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1825
diff changeset
     3
cleanup()
925adaa2cd5c cleanup pyc files between running pytest
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1825
diff changeset
     4
{
925adaa2cd5c cleanup pyc files between running pytest
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1825
diff changeset
     5
    find ./tests/tools -name '*.pyc' -delete
925adaa2cd5c cleanup pyc files between running pytest
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1825
diff changeset
     6
}
925adaa2cd5c cleanup pyc files between running pytest
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1825
diff changeset
     7
1825
bcb50e736a46 run python tests with non-english locale to catch bugs related to localization
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1820
diff changeset
     8
LC_ALL=ru_RU.utf-8
1820
76f5eba31afd add shell script to run all python tests and automatically handle Xvfb
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     9
76f5eba31afd add shell script to run all python tests and automatically handle Xvfb
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    10
export DISPLAY=:42
76f5eba31afd add shell script to run all python tests and automatically handle Xvfb
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    11
Xvfb $DISPLAY -screen 0 1280x1024x24 &
76f5eba31afd add shell script to run all python tests and automatically handle Xvfb
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    12
sleep 1
76f5eba31afd add shell script to run all python tests and automatically handle Xvfb
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    13
2435
925adaa2cd5c cleanup pyc files between running pytest
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1825
diff changeset
    14
925adaa2cd5c cleanup pyc files between running pytest
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1825
diff changeset
    15
cleanup
925adaa2cd5c cleanup pyc files between running pytest
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1825
diff changeset
    16
1820
76f5eba31afd add shell script to run all python tests and automatically handle Xvfb
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    17
ret=0
76f5eba31afd add shell script to run all python tests and automatically handle Xvfb
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    18
DELAY=400
76f5eba31afd add shell script to run all python tests and automatically handle Xvfb
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    19
KILL_DELAY=$(($DELAY + 30))
76f5eba31afd add shell script to run all python tests and automatically handle Xvfb
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    20
timeout -k $KILL_DELAY $DELAY pytest --timeout=10 ./tests/tools
76f5eba31afd add shell script to run all python tests and automatically handle Xvfb
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    21
ret=$?
76f5eba31afd add shell script to run all python tests and automatically handle Xvfb
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    22
2435
925adaa2cd5c cleanup pyc files between running pytest
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1825
diff changeset
    23
cleanup
925adaa2cd5c cleanup pyc files between running pytest
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1825
diff changeset
    24
925adaa2cd5c cleanup pyc files between running pytest
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1825
diff changeset
    25
1820
76f5eba31afd add shell script to run all python tests and automatically handle Xvfb
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    26
pkill -9 Xvfb
76f5eba31afd add shell script to run all python tests and automatically handle Xvfb
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    27
76f5eba31afd add shell script to run all python tests and automatically handle Xvfb
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    28
exit $ret