Chromium Code Reviews| Index: build/android/gyp/lint.py |
| diff --git a/build/android/gyp/lint.py b/build/android/gyp/lint.py |
| index 2d3c79bfcb0c3c1aeeb1cb2b8ce697290228d6ee..59b89be3cc392ddafd36edcf2f4f52061f2db7d6 100755 |
| --- a/build/android/gyp/lint.py |
| +++ b/build/android/gyp/lint.py |
| @@ -136,42 +136,49 @@ 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() |
| + # Sometimes produces empty (almost) files: |
| + if os.path.getsize(result_path) < 10: |
| + if can_fail_build: |
| raise |
| + elif not silent: |
| + traceback.print_exc() |
| + return |
|
jbudorick
2016/03/22 23:46:12
I don't think this should be in the elif.
agrieve
2016/03/23 00:03:07
Done.
|
| + |
| + if can_fail_build and not silent: |
| + traceback.print_exc() |
| - _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() |
| + 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(): |