bdd: Wait less for xfailing tests

We now divide all timeouts by ten for xfailing tests, with the hope to
still catch newly passing tests, but not spend too much time waiting.

With a quick test, this reduced the testsuite run length from 12 to
7-8 minutes.
This commit is contained in:
Florian Bruhin 2016-08-19 13:11:29 +02:00
parent 362c23692a
commit 2eae6a0603
3 changed files with 25 additions and 3 deletions

View File

@ -293,6 +293,15 @@ class QuteProc(testprocess.Process):
function='javaScriptConsoleMessage', function='javaScriptConsoleMessage',
message='[*] {}'.format(message)) message='[*] {}'.format(message))
def wait_for(self, timeout=None, **kwargs):
"""Extend wait_for to add divisor if a test is xfailing."""
xfail = self.request.node.get_marker('xfail')
if xfail and xfail.args[0]:
kwargs['divisor'] = 10
else:
kwargs['divisor'] = 1
return super().wait_for(timeout=timeout, **kwargs)
def _is_error_logline(self, msg): def _is_error_logline(self, msg):
"""Check if the given LogLine is some kind of error message.""" """Check if the given LogLine is some kind of error message."""
is_js_error = (msg.category == 'js' and is_js_error = (msg.category == 'js' and

View File

@ -22,7 +22,6 @@
import logging import logging
import datetime import datetime
import json import json
import collections
import pytest import pytest
@ -50,6 +49,16 @@ class FakeConfig:
def getoption(self, name): def getoption(self, name):
return self.ARGS[name] return self.ARGS[name]
class FakeNode:
"""Fake for request.node"""
def __init__(self, call):
self.rep_call = call
def get_marker(self, _name):
return None
class FakeRequest: class FakeRequest:
@ -70,7 +79,7 @@ def request_mock(quteproc, monkeypatch, httpbin):
"""Patch out a pytest request.""" """Patch out a pytest request."""
fake_call = FakeRepCall() fake_call = FakeRepCall()
fake_config = FakeConfig() fake_config = FakeConfig()
fake_node = collections.namedtuple('FakeNode', ['rep_call'])(fake_call) fake_node = FakeNode(fake_call)
fake_request = FakeRequest(fake_node, fake_config, httpbin) fake_request = FakeRequest(fake_node, fake_config, httpbin)
assert not hasattr(fake_request.node.rep_call, 'wasxfail') assert not hasattr(fake_request.node.rep_call, 'wasxfail')
monkeypatch.setattr(quteproc, 'request', fake_request) monkeypatch.setattr(quteproc, 'request', fake_request)

View File

@ -424,7 +424,7 @@ class Process(QObject):
pass pass
def wait_for(self, timeout=None, *, override_waited_for=False, def wait_for(self, timeout=None, *, override_waited_for=False,
do_skip=False, **kwargs): do_skip=False, divisor=1, **kwargs):
"""Wait until a given value is found in the data. """Wait until a given value is found in the data.
Keyword arguments to this function get interpreted as attributes of the Keyword arguments to this function get interpreted as attributes of the
@ -436,6 +436,7 @@ class Process(QObject):
override_waited_for: If set, gets triggered by previous messages override_waited_for: If set, gets triggered by previous messages
again. again.
do_skip: If set, call pytest.skip on a timeout. do_skip: If set, call pytest.skip on a timeout.
divisor: A factor to decrease the timeout by.
Return: Return:
The matched line. The matched line.
@ -449,6 +450,9 @@ class Process(QObject):
timeout = 15000 timeout = 15000
else: else:
timeout = 5000 timeout = 5000
timeout /= divisor
if not kwargs: if not kwargs:
raise TypeError("No keyword arguments given!") raise TypeError("No keyword arguments given!")
for key in kwargs: for key in kwargs: