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',
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):
"""Check if the given LogLine is some kind of error message."""
is_js_error = (msg.category == 'js' and

View File

@ -22,7 +22,6 @@
import logging
import datetime
import json
import collections
import pytest
@ -50,6 +49,16 @@ class FakeConfig:
def getoption(self, 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:
@ -70,7 +79,7 @@ def request_mock(quteproc, monkeypatch, httpbin):
"""Patch out a pytest request."""
fake_call = FakeRepCall()
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)
assert not hasattr(fake_request.node.rep_call, 'wasxfail')
monkeypatch.setattr(quteproc, 'request', fake_request)

View File

@ -424,7 +424,7 @@ class Process(QObject):
pass
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.
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
again.
do_skip: If set, call pytest.skip on a timeout.
divisor: A factor to decrease the timeout by.
Return:
The matched line.
@ -449,6 +450,9 @@ class Process(QObject):
timeout = 15000
else:
timeout = 5000
timeout /= divisor
if not kwargs:
raise TypeError("No keyword arguments given!")
for key in kwargs: