From 496c14bc9e0afb6c6787a0a167a1cb623ce5e2ff Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 19 Jul 2022 17:54:19 +0200 Subject: quteprocess: Add --qute-delay-start Allows for some rudimentary debugging of subprocesses. --- tests/conftest.py | 4 +++- tests/end2end/fixtures/quteprocess.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) 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') -- cgit v1.2.3-54-g00ecf