From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>
Subject: [PATCH 4/5] u_boot_pylib: Use correct coverage tool within venv
Date: Thu, 20 Jun 2024 07:19:36 -0600 [thread overview]
Message-ID: <20240620131937.1130446-5-sjg@chromium.org> (raw)
In-Reply-To: <20240620131937.1130446-1-sjg@chromium.org>
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>
---
tools/u_boot_pylib/test_util.py | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/tools/u_boot_pylib/test_util.py b/tools/u_boot_pylib/test_util.py
index f18d385d995..857ce58c98c 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'
--
2.34.1
next prev parent reply other threads:[~2024-06-20 13:20 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-20 13:19 [PATCH 0/5] Add Binman code-coverage test to CI Simon Glass
2024-06-20 13:19 ` [PATCH 1/5] Dockerfile: Add python3-coverage Simon Glass
2024-06-20 14:30 ` Tom Rini
2024-06-20 13:19 ` [PATCH 2/5] Dockerfile: Add python3-pycryptodome Simon Glass
2024-06-20 13:19 ` [PATCH 3/5] buildman: Support building within a Python venv Simon Glass
2024-06-20 13:38 ` Heinrich Schuchardt
2024-06-20 23:05 ` Simon Glass
2024-06-20 14:32 ` Tom Rini
2024-06-20 23:05 ` Simon Glass
2024-06-20 23:30 ` Tom Rini
2024-06-21 14:57 ` Simon Glass
2024-06-21 15:22 ` Tom Rini
2024-06-21 18:19 ` Simon Glass
2024-06-21 19:26 ` Tom Rini
2024-06-21 19:39 ` Simon Glass
2024-06-21 20:48 ` Tom Rini
2024-06-20 13:19 ` Simon Glass [this message]
2024-06-20 13:19 ` [PATCH 5/5] CI: Run code-coverage test for Binman Simon Glass
2024-06-20 14:34 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240620131937.1130446-5-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox