tests: Add --qute-strace-subprocs flag

Was needed for #8444 debugging, but might be useful for other issues with
qutebrowser subprocesses as well.
This commit is contained in:
Florian Bruhin 2025-01-06 12:30:14 +01:00 committed by Chad Kouse
parent 600a5c7cfc
commit df15d568bd
No known key found for this signature in database
GPG Key ID: 2BBC602A2578C7A2
2 changed files with 20 additions and 5 deletions

View File

@ -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')

View File

@ -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):