Commit d35de7ef authored by Abhishek Arya's avatar Abhishek Arya Committed by Commit Bot

Coverage: Convert some print to use logging module.

R=mmoroz@chromium.org,liaoyuke@chromium.org

Change-Id: I0951d87c1baee0f172e6e446f2cc6c5a1ae6cf2a
Reviewed-on: https://chromium-review.googlesource.com/1054631Reviewed-by: default avatarMax Moroz <mmoroz@chromium.org>
Reviewed-by: default avatarYuke Liao <liaoyuke@chromium.org>
Commit-Queue: Abhishek Arya <inferno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557696}
parent 0e83e4ec
...@@ -137,6 +137,13 @@ _BUILD_ARGS = None ...@@ -137,6 +137,13 @@ _BUILD_ARGS = None
# Retry failed merges. # Retry failed merges.
MERGE_RETRIES = 3 MERGE_RETRIES = 3
# Message to guide user to file a bug when everything else fails.
FILE_BUG_MESSAGE = (
'If it persists, please file a bug with the command you used, git revision '
'and args.gn config here: '
'https://bugs.chromium.org/p/chromium/issues/entry?'
'components=Tools%3ECodeCoverage')
class _CoverageSummary(object): class _CoverageSummary(object):
"""Encapsulates coverage summary representation.""" """Encapsulates coverage summary representation."""
...@@ -958,26 +965,23 @@ def _GetTargetProfDataPathsByExecutingCommands(targets, commands): ...@@ -958,26 +965,23 @@ def _GetTargetProfDataPathsByExecutingCommands(targets, commands):
assert profraw_file_paths, ( assert profraw_file_paths, (
'Running target "%s" failed to generate any profraw data file, ' 'Running target "%s" failed to generate any profraw data file, '
'please make sure the binary exists and is properly ' 'please make sure the binary exists, is properly instrumented and '
'instrumented.' % target) 'does not crash. %s' % (target, FILE_BUG_MESSAGE))
try: try:
profdata_file_path = _CreateTargetProfDataFileFromProfRawFiles( profdata_file_path = _CreateTargetProfDataFileFromProfRawFiles(
target, profraw_file_paths) target, profraw_file_paths)
break break
except Exception: except Exception:
print('Retrying...') logging.info('Retrying...')
finally: finally:
# Remove profraw files now so that they are not used in next iteration. # Remove profraw files now so that they are not used in next iteration.
for profraw_file_path in profraw_file_paths: for profraw_file_path in profraw_file_paths:
os.remove(profraw_file_path) os.remove(profraw_file_path)
assert profdata_file_path, ( assert profdata_file_path, (
'Failed to merge target "%s" profraw files after %d retries. ' 'Failed to merge target "%s" profraw files after %d retries. %s' %
'Please file a bug with command you used, commit position and args.gn ' (target, MERGE_RETRIES, FILE_BUG_MESSAGE))
'config here: '
'https://bugs.chromium.org/p/chromium/issues/entry?'
'components=Tools%%3ECodeCoverage' % (target, MERGE_RETRIES))
profdata_file_paths.append(profdata_file_path) profdata_file_paths.append(profdata_file_path)
logging.debug('Finished executing the test commands.') logging.debug('Finished executing the test commands.')
...@@ -1117,8 +1121,9 @@ def _CreateCoverageProfileDataFromTargetProfDataFiles(profdata_file_paths): ...@@ -1117,8 +1121,9 @@ def _CreateCoverageProfileDataFromTargetProfDataFiles(profdata_file_paths):
subprocess_cmd.extend(profdata_file_paths) subprocess_cmd.extend(profdata_file_paths)
subprocess.check_call(subprocess_cmd) subprocess.check_call(subprocess_cmd)
except subprocess.CalledProcessError as error: except subprocess.CalledProcessError as error:
print('Failed to merge target profdata files to create coverage profdata. ' logging.error(
'Try again.') 'Failed to merge target profdata files to create coverage profdata. %s',
FILE_BUG_MESSAGE)
raise error raise error
logging.debug('Finished merging target profdata files.') logging.debug('Finished merging target profdata files.')
...@@ -1152,7 +1157,8 @@ def _CreateTargetProfDataFileFromProfRawFiles(target, profraw_file_paths): ...@@ -1152,7 +1157,8 @@ def _CreateTargetProfDataFileFromProfRawFiles(target, profraw_file_paths):
subprocess_cmd.extend(profraw_file_paths) subprocess_cmd.extend(profraw_file_paths)
subprocess.check_call(subprocess_cmd) subprocess.check_call(subprocess_cmd)
except subprocess.CalledProcessError as error: except subprocess.CalledProcessError as error:
print('Failed to merge target profraw files to create target profdata.') logging.error(
'Failed to merge target profraw files to create target profdata.')
raise error raise error
logging.debug('Finished merging target profraw files.') logging.debug('Finished merging target profraw files.')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment