mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-27 16:01:27 +00:00
u_boot_pylib: Use correct coverage tool within venv
When running within a Python venv we must use the 'coverage' tool (which is within the venv) so that the venv packages are used in preference to system packages. Otherwise the coverage tests run in a different environment from the normal tests and may fail due to missing packages. Handle this by detecting the venv and changing the tool name. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
6c0a3cf75f
commit
0318126236
1 changed files with 8 additions and 3 deletions
|
@ -60,12 +60,17 @@ def run_test_coverage(prog, filter_fname, exclude_list, build_dir, required=None
|
|||
prefix = ''
|
||||
if build_dir:
|
||||
prefix = 'PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools ' % build_dir
|
||||
cmd = ('%spython3-coverage run '
|
||||
'--omit "%s" %s %s %s %s' % (prefix, ','.join(glob_list),
|
||||
|
||||
# Detect a Python virtualenv and use 'coverage' instead
|
||||
covtool = ('python3-coverage' if sys.prefix == sys.base_prefix else
|
||||
'coverage')
|
||||
|
||||
cmd = ('%s%s run '
|
||||
'--omit "%s" %s %s %s %s' % (prefix, covtool, ','.join(glob_list),
|
||||
prog, extra_args or '', test_cmd,
|
||||
single_thread or '-P1'))
|
||||
os.system(cmd)
|
||||
stdout = command.output('python3-coverage', 'report')
|
||||
stdout = command.output(covtool, 'report')
|
||||
lines = stdout.splitlines()
|
||||
if required:
|
||||
# Convert '/path/to/name.py' just the module name 'name'
|
||||
|
|
Loading…
Add table
Reference in a new issue