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

Unified Diff: mojo/public/tools/dart_analyze.py

Issue 1060053003: Don't output duplicate errors from dart analyzer. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 8 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: mojo/public/tools/dart_analyze.py
diff --git a/mojo/public/tools/dart_analyze.py b/mojo/public/tools/dart_analyze.py
index 448bf74bb1b41a5e3d41f9f3cb0c1c0af3b56f2e..cb80804bad44416dafe85bebb4e5d2ed40e84be4 100755
--- a/mojo/public/tools/dart_analyze.py
+++ b/mojo/public/tools/dart_analyze.py
@@ -19,13 +19,17 @@ import sys
import tempfile
import zipfile
-_ANALYZING_PATTERN = re.compile(r'^Analyzing \[')
-_NO_ISSUES_FOUND_PATTERN = re.compile(r'^No issues found')
-_PART_WARNINGS_PATTERN = re.compile(
- r'.*is a part and can not|^Only libraries can be analyzed')
-_ERRORS_AND_WARNINGS_PATTERN = re.compile(
- r'^[0-9]+ errors? and [0-9]+ warnings? found.')
-_ERRORS_PATTERN = re.compile(r'^([0-9]+|No) (error|warning|issue)s? found.')
+_IGNORED_PATTERNS = [
+ # Ignored because they're not indicative of specific errors.
+ re.compile(r'^$'),
+ re.compile(r'^Analyzing \['),
+ re.compile(r'^No issues found'),
+ re.compile(r'^[0-9]+ errors? and [0-9]+ warnings? found.'),
+ re.compile(r'^([0-9]+|No) (error|warning|issue)s? found.'),
+
+ # TODO: It seems like this should be re-enabled evenutally.
+ re.compile(r'.*is a part and can not|^Only libraries can be analyzed'),
+]
def _success(stamp_file):
# We passed cleanly, so touch the stamp file so that we don't run again.
@@ -63,29 +67,18 @@ def main(args):
cmd.append("--package-root=%s" % temp_dir)
cmd.append("--fatal-warnings")
- passed = True
+ errors = 0
try:
subprocess.check_output(cmd, shell=False, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
- # Perform post processing on the output. Filter out non-error messages and
- # known problem patterns that we're working on.
- raw_lines = e.output.split('\n')
- # Remove the last empty line
- raw_lines.pop()
- filtered_lines = [i for i in raw_lines if (
- not re.match(_ANALYZING_PATTERN, i) and
- not re.match(_NO_ISSUES_FOUND_PATTERN, i) and
- not re.match(_PART_WARNINGS_PATTERN, i) and
- not re.match(_ERRORS_AND_WARNINGS_PATTERN, i) and
- not re.match(_ERRORS_PATTERN, i))]
- for line in filtered_lines:
- passed = False
- print >> sys.stderr, line.replace(temp_dir + "/", dartzip_basename)
-
- if passed:
+ errors = set(l for l in e.output.split('\n')
+ if not any(p.match(l) for p in _IGNORED_PATTERNS))
+ for error in sorted(errors):
+ print >> sys.stderr, error.replace(temp_dir + "/", dartzip_basename)
+
+ if not errors:
return _success(stamp_file)
- else:
- return -2
+ return min(255, len(errors))
finally:
shutil.rmtree(temp_dir)
« 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