aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2024-06-23 11:56:21 -0600
committerSimon Glass <sjg@chromium.org>2024-07-03 07:36:33 +0100
commit0318126236da1474ae1b6e349d83991fb0cda8ea (patch)
tree93fff3e4e31f9d7a1cb1a24a7651d4aea4695177 /tools
parent6c0a3cf75f72370deec3ee516a9dd377397af207 (diff)
downloadu-boot-0318126236da1474ae1b6e349d83991fb0cda8ea.zip
u-boot-0318126236da1474ae1b6e349d83991fb0cda8ea.tar.gz
u-boot-0318126236da1474ae1b6e349d83991fb0cda8ea.tar.bz2
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>
Diffstat (limited to 'tools')
-rw-r--r--tools/u_boot_pylib/test_util.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/tools/u_boot_pylib/test_util.py b/tools/u_boot_pylib/test_util.py
index f18d385..857ce58 100644
--- a/tools/u_boot_pylib/test_util.py
+++ b/tools/u_boot_pylib/test_util.py
@@ -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'