mirror of
https://xff.cz/git/u-boot/
synced 2025-09-27 13:31:16 +02:00
patman: Update cover-coverage tests for Python 3
We need slightly different commands to run code coverage with Python 3. Update the RunTestCoverage() function to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -17,6 +17,8 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
|
||||||
|
PYTHON = 'python%d' % sys.version_info[0]
|
||||||
|
|
||||||
|
|
||||||
def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None):
|
def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None):
|
||||||
"""Run tests and check that we get 100% coverage
|
"""Run tests and check that we get 100% coverage
|
||||||
@@ -43,11 +45,12 @@ def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None):
|
|||||||
else:
|
else:
|
||||||
glob_list = []
|
glob_list = []
|
||||||
glob_list += exclude_list
|
glob_list += exclude_list
|
||||||
glob_list += ['*libfdt.py', '*site-packages*']
|
glob_list += ['*libfdt.py', '*site-packages*', '*dist-packages*']
|
||||||
cmd = ('PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools python-coverage run '
|
cmd = ('PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools %s-coverage run '
|
||||||
'--omit "%s" %s -P1 -t' % (build_dir, ','.join(glob_list), prog))
|
'--omit "%s" %s -P1 -t' % (build_dir, PYTHON, ','.join(glob_list),
|
||||||
|
prog))
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
stdout = command.Output('python-coverage', 'report')
|
stdout = command.Output('%s-coverage' % PYTHON, 'report')
|
||||||
lines = stdout.splitlines()
|
lines = stdout.splitlines()
|
||||||
if required:
|
if required:
|
||||||
# Convert '/path/to/name.py' just the module name 'name'
|
# Convert '/path/to/name.py' just the module name 'name'
|
||||||
@@ -65,8 +68,8 @@ def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None):
|
|||||||
print(coverage)
|
print(coverage)
|
||||||
if coverage != '100%':
|
if coverage != '100%':
|
||||||
print(stdout)
|
print(stdout)
|
||||||
print("Type 'python-coverage html' to get a report in "
|
print("Type '%s-coverage html' to get a report in "
|
||||||
'htmlcov/index.html')
|
'htmlcov/index.html' % PYTHON)
|
||||||
print('Coverage error: %s, but should be 100%%' % coverage)
|
print('Coverage error: %s, but should be 100%%' % coverage)
|
||||||
ok = False
|
ok = False
|
||||||
if not ok:
|
if not ok:
|
||||||
|
Reference in New Issue
Block a user