summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2022-07-19 17:54:19 +0200
committerFlorian Bruhin <me@the-compiler.org>2022-08-23 18:31:42 +0200
commit496c14bc9e0afb6c6787a0a167a1cb623ce5e2ff (patch)
treebbcca812a494b13351a5334f886e32bc7a1ba988
parentd31b2e20168517cbcb6f3aa43c5e8d4762724131 (diff)
downloadqutebrowser-496c14bc9e0afb6c6787a0a167a1cb623ce5e2ff.tar.gz
qutebrowser-496c14bc9e0afb6c6787a0a167a1cb623ce5e2ff.zip
quteprocess: Add --qute-delay-start
Allows for some rudimentary debugging of subprocesses.
-rw-r--r--tests/conftest.py4
-rw-r--r--tests/end2end/fixtures/quteprocess.py15
2 files changed, 18 insertions, 1 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 48e5660ee..c74d67566 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -219,7 +219,9 @@ def qapp(qapp):
def pytest_addoption(parser):
parser.addoption('--qute-delay', action='store', default=0, type=int,
- help="Delay between qutebrowser commands.")
+ help="Delay (in ms) between qutebrowser commands.")
+ parser.addoption('--qute-delay-start', action='store', default=0, type=int,
+ help="Delay (in ms) after qutebrowser process started.")
parser.addoption('--qute-profile-subprocs', action='store_true',
default=False, help="Run cProfile for subprocesses.")
parser.addoption('--qute-backend', action='store',
diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py
index 92504fbbc..21389edca 100644
--- a/tests/end2end/fixtures/quteprocess.py
+++ b/tests/end2end/fixtures/quteprocess.py
@@ -457,6 +457,21 @@ class QuteProc(testprocess.Process):
self.wait_for(category='ipc', module='ipc', function='on_ready_read',
message='Read from socket *')
+ @contextlib.contextmanager
+ def disable_capturing(self):
+ capmanager = self.request.config.pluginmanager.getplugin("capturemanager")
+ with capmanager.global_and_fixture_disabled():
+ yield
+
+ def _after_start(self):
+ """Wait before continuing if requested, e.g. for debugger attachment."""
+ delay = self.request.config.getoption('--qute-delay-start')
+ if delay:
+ with self.disable_capturing():
+ print(f"- waiting {delay}ms for quteprocess "
+ f"(PID: {self.proc.processId()})...")
+ time.sleep(delay / 1000)
+
def send_ipc(self, commands, target_arg=''):
"""Send a raw command to the running IPC socket."""
delay = self.request.config.getoption('--qute-delay')