Get rid of run_pytest.py

Fixes #2452
This commit is contained in:
Florian Bruhin 2017-03-18 21:03:52 +01:00
parent dc50c6ac3d
commit 069f908a61
3 changed files with 9 additions and 84 deletions

View File

@ -1,57 +0,0 @@
#!/usr/bin/env python3
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
# Copyright 2016 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
#
# This file is part of qutebrowser.
#
# qutebrowser is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# qutebrowser is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
"""Wrapper around pytest to ignore segfaults on exit."""
import os
import sys
import subprocess
import signal
if __name__ == '__main__':
script_path = os.path.abspath(os.path.dirname(__file__))
pytest_status_file = os.path.join(script_path, '..', '..', '.cache',
'pytest_status')
try:
os.remove(pytest_status_file)
except FileNotFoundError:
pass
try:
subprocess.check_call([sys.executable, '-m', 'pytest'] + sys.argv[1:])
except subprocess.CalledProcessError as exc:
is_segfault = exc.returncode in [128 + signal.SIGSEGV, -signal.SIGSEGV]
if is_segfault and os.path.exists(pytest_status_file):
print("Ignoring segfault on exit!")
with open(pytest_status_file, 'r', encoding='ascii') as f:
exit_status = int(f.read())
else:
exit_status = exc.returncode
else:
exit_status = 0
try:
os.remove(pytest_status_file)
except FileNotFoundError:
pass
sys.exit(exit_status)

View File

@ -192,21 +192,3 @@ def pytest_runtest_makereport(item, call):
outcome = yield
rep = outcome.get_result()
setattr(item, "rep_" + rep.when, rep)
@pytest.hookimpl(hookwrapper=True)
def pytest_sessionfinish(exitstatus):
"""Create a file to tell run_pytest.py how pytest exited."""
outcome = yield
outcome.get_result()
cache_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)),
'..', '.cache')
try:
os.mkdir(cache_dir)
except FileExistsError:
pass
status_file = os.path.join(cache_dir, 'pytest_status')
with open(status_file, 'w', encoding='ascii') as f:
f.write(str(exitstatus))

18
tox.ini
View File

@ -19,7 +19,7 @@ deps =
-r{toxinidir}/misc/requirements/requirements-tests.txt
commands =
{envpython} scripts/link_pyqt.py --tox {envdir}
{envpython} scripts/dev/run_pytest.py {posargs:tests}
{envpython} -m pytest {posargs:tests}
# test envs with coverage
@ -31,7 +31,7 @@ passenv = {[testenv]passenv}
deps = {[testenv]deps}
commands =
{envpython} scripts/link_pyqt.py --tox {envdir}
{envpython} scripts/dev/run_pytest.py --cov --cov-report xml --cov-report=html --cov-report= {posargs:tests}
{envpython} -m pytest --cov --cov-report xml --cov-report=html --cov-report= {posargs:tests}
{envpython} scripts/dev/check_coverage.py {posargs}
[testenv:py35-cov]
@ -41,7 +41,7 @@ passenv = {[testenv]passenv}
deps = {[testenv]deps}
commands =
{envpython} scripts/link_pyqt.py --tox {envdir}
{envpython} scripts/dev/run_pytest.py --cov --cov-report xml --cov-report=html --cov-report= {posargs:tests}
{envpython} -m pytest --cov --cov-report xml --cov-report=html --cov-report= {posargs:tests}
{envpython} scripts/dev/check_coverage.py {posargs}
[testenv:py34-cov]
@ -51,7 +51,7 @@ passenv = {[testenv]passenv}
deps = {[testenv]deps}
commands =
{envpython} scripts/link_pyqt.py --tox {envdir}
{envpython} scripts/dev/run_pytest.py --cov --cov-report xml --cov-report=html --cov-report= {posargs:tests}
{envpython} -m pytest --cov --cov-report xml --cov-report=html --cov-report= {posargs:tests}
{envpython} scripts/dev/check_coverage.py {posargs}
# test envs with PyQt5 from PyPI
@ -65,7 +65,7 @@ passenv = {[testenv]passenv}
deps =
{[testenv]deps}
PyQt5==5.6
commands = {envpython} scripts/dev/run_pytest.py {posargs:tests}
commands = {envpython} -m pytest {posargs:tests}
[testenv:py35-pyqt571]
basepython = python3.5
@ -76,7 +76,7 @@ passenv = {[testenv]passenv}
deps =
{[testenv]deps}
PyQt5==5.7.1
commands = {envpython} scripts/dev/run_pytest.py {posargs:tests}
commands = {envpython} -m pytest {posargs:tests}
[testenv:py36-pyqt571]
basepython = python3.6
@ -87,7 +87,7 @@ passenv = {[testenv]passenv}
deps =
{[testenv]deps}
PyQt5==5.7.1
commands = {envpython} scripts/dev/run_pytest.py {posargs:tests}
commands = {envpython} -m pytest {posargs:tests}
[testenv:py35-pyqt58]
basepython = python3.5
@ -98,7 +98,7 @@ passenv = {[testenv]passenv}
deps =
{[testenv]deps}
PyQt5==5.8.1.1
commands = {envpython} scripts/dev/run_pytest.py {posargs:tests}
commands = {envpython} -m pytest {posargs:tests}
[testenv:py36-pyqt58]
basepython = python3.6
@ -109,7 +109,7 @@ passenv = {[testenv]passenv}
deps =
{[testenv]deps}
PyQt5==5.8.1.1
commands = {envpython} scripts/dev/run_pytest.py {posargs:tests}
commands = {envpython} -m pytest {posargs:tests}
# other envs