Skip to content

Commit

Permalink
test/cli/testutils.py: added environment variable `TEST_CPPCHECK_INJE…
Browse files Browse the repository at this point in the history
…CT_EXECUTOR` to inject `--executor` into cppcheck execution
  • Loading branch information
firewave committed Mar 4, 2024
1 parent 2464a9d commit 7125290
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/cli/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@ def cppcheck(args, env=None, remove_checkers_report=True, cwd=None, cppcheck_exe
exe = cppcheck_exe if cppcheck_exe else __lookup_cppcheck_exe()
assert exe is not None, 'no cppcheck binary found'

if 'TEST_CPPCHECK_INJECT_EXECUTOR' in os.environ:
found_jn = False
found_executor = False
for arg in args:
if arg.startswith('-j') and arg != '-j1':
found_jn = True
continue
if arg.startswith('--executor'):
found_executor = True
continue
# only add '--executor' if we are actually using multiple jobs
if found_jn and not found_executor:
arg_executor = '--executor=' + str(os.environ['TEST_CPPCHECK_INJECT_EXECUTOR'])
args.append(arg_executor)

logging.info(exe + ' ' + ' '.join(args))
p = subprocess.Popen([exe] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, cwd=cwd)
try:
Expand Down

0 comments on commit 7125290

Please sign in to comment.