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

Side by Side Diff: mojo/public/tools/dart_analyze.py

Issue 996923003: Dart: Better handle leak checks. close() is async. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # To integrate dartanalyze with out build system, we take an input file, run 6 # To integrate dartanalyze with out build system, we take an input file, run
7 # the analyzer on it, and write a stamp file if it passed. 7 # the analyzer on it, and write a stamp file if it passed.
8 # 8 #
9 # The first argument to this script is a reference to this build's gen 9 # The first argument to this script is a reference to this build's gen
10 # directory, which we treat as the package root. The second is the stamp file 10 # directory, which we treat as the package root. The second is the stamp file
11 # to touch if we succeed. The rest are passed to the analyzer verbatim. 11 # to touch if we succeed. The rest are passed to the analyzer verbatim.
12 12
13 import glob 13 import glob
14 import os 14 import os
15 import re 15 import re
16 import shutil 16 import shutil
17 import subprocess 17 import subprocess
18 import sys 18 import sys
19 import tempfile 19 import tempfile
20 import zipfile 20 import zipfile
21 21
22 _ANALYZING_PATTERN = re.compile(r'^Analyzing \[') 22 _ANALYZING_PATTERN = re.compile(r'^Analyzing \[')
23 _FINAL_REPORT_PATTERN = re.compile(r'^[0-9]+ errors and [0-9]+ warnings found.') 23 _FINAL_REPORT_PATTERN = re.compile(
24 r'^[0-9]+ errors( and [0-9]+ warnings)* found.')
Elliot Glaysher 2015/03/10 21:11:02 You probably also want to add ? to the two 's' cha
zra 2015/03/10 21:28:37 I just took the regexes from your CL =)
24 25
25 _NATIVE_ERROR_PATTERN = re.compile( 26 _NATIVE_ERROR_PATTERN = re.compile(
26 r'^\[error\] Native functions can only be declared in the SDK and code that ' 27 r'^\[error\] Native functions can only be declared in the SDK and code that '
27 r'is loaded through native extensions') 28 r'is loaded through native extensions')
28 _WARNING_PATTERN = re.compile(r'^\[warning\]')
29 _THAT_ONE_BROKEN_CLOSE_IN_WEB_SOCKETS_PATTERN = re.compile(
30 r'^\[error\] The name \'close\' is already defined')
31
32 29
33 def main(args): 30 def main(args):
34 dartzip_file = args.pop(0) 31 dartzip_file = args.pop(0)
35 stamp_file = args.pop(0) 32 stamp_file = args.pop(0)
36 33
37 dartzip_basename = os.path.basename(dartzip_file) + ":" 34 dartzip_basename = os.path.basename(dartzip_file) + ":"
38 35
39 # Unzip |dartzip_file| to a temporary directory. 36 # Unzip |dartzip_file| to a temporary directory.
40 try: 37 try:
41 temp_dir = tempfile.mkdtemp() 38 temp_dir = tempfile.mkdtemp()
(...skipping 16 matching lines...) Expand all
58 except subprocess.CalledProcessError as e: 55 except subprocess.CalledProcessError as e:
59 # Perform post processing on the output. Filter out non-error messages and 56 # Perform post processing on the output. Filter out non-error messages and
60 # known problem patterns that we're working on. 57 # known problem patterns that we're working on.
61 raw_lines = e.output.split('\n') 58 raw_lines = e.output.split('\n')
62 # Remove the last empty line 59 # Remove the last empty line
63 raw_lines.pop() 60 raw_lines.pop()
64 filtered_lines = [i for i in raw_lines if ( 61 filtered_lines = [i for i in raw_lines if (
65 not re.match(_ANALYZING_PATTERN, i) and 62 not re.match(_ANALYZING_PATTERN, i) and
66 not re.match(_FINAL_REPORT_PATTERN, i) and 63 not re.match(_FINAL_REPORT_PATTERN, i) and
67 # TODO(erg): Remove the rest of these as fixes land: 64 # TODO(erg): Remove the rest of these as fixes land:
68 not re.match(_WARNING_PATTERN, i) and 65 not re.match(_NATIVE_ERROR_PATTERN, i))]
69 not re.match(_NATIVE_ERROR_PATTERN, i) and
70 not re.match(_THAT_ONE_BROKEN_CLOSE_IN_WEB_SOCKETS_PATTERN, i))]
71 for line in filtered_lines: 66 for line in filtered_lines:
72 passed = False 67 passed = False
73 print >> sys.stderr, line.replace(temp_dir + "/", dartzip_basename) 68 print >> sys.stderr, line.replace(temp_dir + "/", dartzip_basename)
74 69
75 if passed: 70 if passed:
76 # We passed cleanly, so touch the stamp file so that we don't run again. 71 # We passed cleanly, so touch the stamp file so that we don't run again.
77 with open(stamp_file, 'a'): 72 with open(stamp_file, 'a'):
78 os.utime(stamp_file, None) 73 os.utime(stamp_file, None)
79 return 0 74 return 0
80 else: 75 else:
81 return -2 76 return -2
82 finally: 77 finally:
83 shutil.rmtree(temp_dir) 78 shutil.rmtree(temp_dir)
84 79
85 80
86 if __name__ == '__main__': 81 if __name__ == '__main__':
87 sys.exit(main(sys.argv[1:])) 82 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698