diff --git a/tests/conftest.py b/tests/conftest.py index e151a7fed..44f3d7794 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -239,6 +239,8 @@ def pytest_addoption(parser): 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-strace-subprocs', action='store_true', + default=False, help="Run strace for subprocesses.") parser.addoption('--qute-backend', action='store', choices=['webkit', 'webengine'], help='Set backend for BDD tests') diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py index 42d8f7885..f63123538 100644 --- a/tests/end2end/fixtures/quteprocess.py +++ b/tests/end2end/fixtures/quteprocess.py @@ -399,24 +399,37 @@ class QuteProc(testprocess.Process): def _executable_args(self): profile = self.request.config.getoption('--qute-profile-subprocs') + strace = self.request.config.getoption('--qute-strace-subprocs') if hasattr(sys, 'frozen'): - if profile: - raise RuntimeError("Can't profile with sys.frozen!") + if profile or strace: + raise RuntimeError("Can't profile/strace with sys.frozen!") executable = str(pathlib.Path(sys.executable).parent / 'qutebrowser') args = [] else: - executable = sys.executable + if strace: + executable = 'strace' + args = [ + "-o", + "qb-strace", + "--output-separately", # create .PID files + "--write=2", # dump full stderr data (qb JSON logs) + sys.executable, + ] + else: + executable = sys.executable + args = [] + if profile: profile_dir = pathlib.Path.cwd() / 'prof' profile_id = '{}_{}'.format(self._instance_id, next(self._run_counter)) profile_file = profile_dir / '{}.pstats'.format(profile_id) profile_dir.mkdir(exist_ok=True) - args = [str(pathlib.Path('scripts') / 'dev' / 'run_profile.py'), + args += [str(pathlib.Path('scripts') / 'dev' / 'run_profile.py'), '--profile-tool', 'none', '--profile-file', str(profile_file)] else: - args = ['-bb', '-m', 'qutebrowser'] + args += ['-bb', '-m', 'qutebrowser'] return executable, args def _default_args(self):