summaryrefslogtreecommitdiff
path: root/tools/patman/test_util.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/patman/test_util.py')
-rw-r--r--tools/patman/test_util.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/tools/patman/test_util.py b/tools/patman/test_util.py
index 687d40704a..ea36cd1633 100644
--- a/tools/patman/test_util.py
+++ b/tools/patman/test_util.py
@@ -3,6 +3,8 @@
# Copyright (c) 2016 Google, Inc
#
+from __future__ import print_function
+
from contextlib import contextmanager
import glob
import os
@@ -15,6 +17,8 @@ try:
except ImportError:
from io import StringIO
+PYTHON = 'python%d' % sys.version_info[0]
+
def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None):
"""Run tests and check that we get 100% coverage
@@ -41,11 +45,12 @@ def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None):
else:
glob_list = []
glob_list += exclude_list
- glob_list += ['*libfdt.py', '*site-packages*']
- cmd = ('PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools python-coverage run '
- '--omit "%s" %s -P1 -t' % (build_dir, ','.join(glob_list), prog))
+ glob_list += ['*libfdt.py', '*site-packages*', '*dist-packages*']
+ cmd = ('PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools %s-coverage run '
+ '--omit "%s" %s -P1 -t' % (build_dir, PYTHON, ','.join(glob_list),
+ prog))
os.system(cmd)
- stdout = command.Output('python-coverage', 'report')
+ stdout = command.Output('%s-coverage' % PYTHON, 'report')
lines = stdout.splitlines()
if required:
# Convert '/path/to/name.py' just the module name 'name'
@@ -54,18 +59,18 @@ def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None):
missing_list = required
missing_list.difference_update(test_set)
if missing_list:
- print 'Missing tests for %s' % (', '.join(missing_list))
- print stdout
+ print('Missing tests for %s' % (', '.join(missing_list)))
+ print(stdout)
ok = False
coverage = lines[-1].split(' ')[-1]
ok = True
- print coverage
+ print(coverage)
if coverage != '100%':
- print stdout
- print ("Type 'python-coverage html' to get a report in "
- 'htmlcov/index.html')
- print 'Coverage error: %s, but should be 100%%' % coverage
+ print(stdout)
+ print("Type '%s-coverage html' to get a report in "
+ 'htmlcov/index.html' % PYTHON)
+ print('Coverage error: %s, but should be 100%%' % coverage)
ok = False
if not ok:
raise ValueError('Test coverage failure')