diff options
author | agrieve <agrieve@chromium.org> | 2016-03-23 08:17:19 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-23 15:18:57 +0000 |
commit | ffd77282c9d5152af0d5fd09cf1a9d39221f0e62 (patch) | |
tree | ec76dfc5cee0f1809adb1677fa696589e5538738 /build | |
parent | 660ee3c9fc851b47bc17c086ae5222d1e6212e60 (diff) | |
download | chromium_src-ffd77282c9d5152af0d5fd09cf1a9d39221f0e62.zip chromium_src-ffd77282c9d5152af0d5fd09cf1a9d39221f0e62.tar.gz chromium_src-ffd77282c9d5152af0d5fd09cf1a9d39221f0e62.tar.bz2 |
lint.py - print original exception for empty results.xml
BUG=583661
Review URL: https://codereview.chromium.org/1823173002
Cr-Commit-Position: refs/heads/master@{#382848}
Diffstat (limited to 'build')
-rwxr-xr-x | build/android/gyp/lint.py | 79 |
1 files changed, 48 insertions, 31 deletions
diff --git a/build/android/gyp/lint.py b/build/android/gyp/lint.py index 9814bf0..2df89e1 100755 --- a/build/android/gyp/lint.py +++ b/build/android/gyp/lint.py @@ -136,44 +136,61 @@ def _OnStaleMd5(changes, lint_path, config_path, processed_config_path, try: build_utils.CheckOutput(cmd, cwd=_SRC_ROOT, env=env or None) except build_utils.CalledProcessError: - if can_fail_build: - traceback.print_exc() - # There is a problem with lint usage if not os.path.exists(result_path): raise - # There are actual lint issues - else: - try: - num_issues = _ParseAndShowResultFile() - except Exception: # pylint: disable=broad-except - if not silent: - print 'Lint created unparseable xml file...' - print 'File contents:' - with open(result_path) as f: - print f.read() - if not can_fail_build: - return + # Sometimes produces empty (almost) files: + if os.path.getsize(result_path) < 10: + if can_fail_build: raise + elif not silent: + traceback.print_exc() + return - _ProcessResultFile() - msg = ('\nLint found %d new issues.\n' - ' - For full explanation refer to %s\n' % - (num_issues, - _RelativizePath(result_path))) - if config_path: - msg += (' - Wanna suppress these issues?\n' - ' 1. Read comment in %s\n' - ' 2. Run "python %s %s"\n' % - (_RelativizePath(config_path), - _RelativizePath(os.path.join(_SRC_ROOT, 'build', 'android', - 'lint', 'suppress.py')), - _RelativizePath(result_path))) + # There are actual lint issues + try: + num_issues = _ParseAndShowResultFile() + except Exception: # pylint: disable=broad-except if not silent: - print >> sys.stderr, msg - if can_fail_build: - raise Exception('Lint failed.') + print 'Lint created unparseable xml file...' + print 'File contents:' + with open(result_path) as f: + print f.read() + if not can_fail_build: + return + + if can_fail_build and not silent: + traceback.print_exc() + + # There are actual lint issues + try: + num_issues = _ParseAndShowResultFile() + except Exception: # pylint: disable=broad-except + if not silent: + print 'Lint created unparseable xml file...' + print 'File contents:' + with open(result_path) as f: + print f.read() + raise + + _ProcessResultFile() + msg = ('\nLint found %d new issues.\n' + ' - For full explanation refer to %s\n' % + (num_issues, + _RelativizePath(result_path))) + if config_path: + msg += (' - Wanna suppress these issues?\n' + ' 1. Read comment in %s\n' + ' 2. Run "python %s %s"\n' % + (_RelativizePath(config_path), + _RelativizePath(os.path.join(_SRC_ROOT, 'build', 'android', + 'lint', 'suppress.py')), + _RelativizePath(result_path))) + if not silent: + print >> sys.stderr, msg + if can_fail_build: + raise Exception('Lint failed.') def main(): |