Message ID | 20220824074342.28677-1-msuchanek@suse.de |
---|---|
State | Superseded |
Headers | show |
Series | patman: do not hardcode coverage tool | expand |
Hi Michal, On Wed, 24 Aug 2022 at 00:43, Michal Suchanek <msuchanek@suse.de> wrote: > > The coverage tool name varies across distributions. > > Add COVERAGE variable to specify the tool name. > > Also there is one place where prefix is prepended to the tool path, > remove the prefix. > > Signed-off-by: Michal Suchanek <msuchanek@suse.de> > --- > tools/patman/test_util.py | 18 ++++++++++-------- > 1 file changed, 10 insertions(+), 8 deletions(-) Reviewed-by: Simon Glass <sjg@chromium.org> But please update the docs. Regards, Simon
Hi Michal, On 8/24/22 09:43, Michal Suchanek wrote: > The coverage tool name varies across distributions. > > Add COVERAGE variable to specify the tool name. > > Also there is one place where prefix is prepended to the tool path, > remove the prefix. > > Signed-off-by: Michal Suchanek <msuchanek@suse.de> > --- > tools/patman/test_util.py | 18 ++++++++++-------- > 1 file changed, 10 insertions(+), 8 deletions(-) > > diff --git a/tools/patman/test_util.py b/tools/patman/test_util.py > index 0f6d1aa902..e11806b626 100644 > --- a/tools/patman/test_util.py > +++ b/tools/patman/test_util.py > @@ -15,6 +15,8 @@ from patman import command > > from io import StringIO > > +coverage = os.environ.get('COVERAGE', 'python3-coverage') > + > buffer_outputs = True > use_concurrent = True > try: > @@ -58,11 +60,11 @@ 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 -P1' % (prefix, ','.join(glob_list), > + cmd = ('%s run ' > + '--omit "%s" %s %s %s -P1' % (coverage, ','.join(glob_list), > prog, extra_args or '', test_cmd)) > os.system(cmd) > - stdout = command.output('python3-coverage', 'report') > + stdout = command.output(coverage, 'report') Please use: command.run_pipe((coverage + ' report').split(), capture=True, raise_on_error=True) instead, so that COVERAGE can contain "python3 -m coverage". (or if you know a way of unpacking a list, pass (coverage + ' report') unpacked to command.output()). Cheers, Quentin
diff --git a/tools/patman/test_util.py b/tools/patman/test_util.py index 0f6d1aa902..e11806b626 100644 --- a/tools/patman/test_util.py +++ b/tools/patman/test_util.py @@ -15,6 +15,8 @@ from patman import command from io import StringIO +coverage = os.environ.get('COVERAGE', 'python3-coverage') + buffer_outputs = True use_concurrent = True try: @@ -58,11 +60,11 @@ 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 -P1' % (prefix, ','.join(glob_list), + cmd = ('%s run ' + '--omit "%s" %s %s %s -P1' % (coverage, ','.join(glob_list), prog, extra_args or '', test_cmd)) os.system(cmd) - stdout = command.output('python3-coverage', 'report') + stdout = command.output(coverage, 'report') lines = stdout.splitlines() if required: # Convert '/path/to/name.py' just the module name 'name' @@ -76,13 +78,13 @@ def run_test_coverage(prog, filter_fname, exclude_list, build_dir, required=None print(stdout) ok = False - coverage = lines[-1].split(' ')[-1] + cov_result = lines[-1].split(' ')[-1] ok = True - print(coverage) - if coverage != '100%': + print(cov_result) + if cov_result != '100%': print(stdout) - print("To get a report in 'htmlcov/index.html', type: python3-coverage html") - print('Coverage error: %s, but should be 100%%' % coverage) + print("To get a report in 'htmlcov/index.html', type: %s html" % coverage) + print('Coverage error: %s, but should be 100%%' % cov_result) ok = False if not ok: raise ValueError('Test coverage failure')
The coverage tool name varies across distributions. Add COVERAGE variable to specify the tool name. Also there is one place where prefix is prepended to the tool path, remove the prefix. Signed-off-by: Michal Suchanek <msuchanek@suse.de> --- tools/patman/test_util.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)