Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(548)

Unified Diff: build/android/gyp/lint.py

Issue 1823173002: 🌇 lint.py - print original exception for empty results.xml (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/gyp/lint.py
diff --git a/build/android/gyp/lint.py b/build/android/gyp/lint.py
index 0aad9c5e1fb858db290fa8aab23a1fbe714305aa..e258c0a948ef1df185dd01e246cd1c599b0d8f57 100755
--- a/build/android/gyp/lint.py
+++ b/build/android/gyp/lint.py
@@ -141,44 +141,61 @@ def _OnStaleMd5(changes, lint_path, config_path, processed_config_path,
build_utils.CheckOutput(cmd, cwd=_SRC_ROOT, env=env or None,
stderr_filter=stderr_filter)
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():
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698