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

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

Issue 953953003: Introduce dartanalyze into our build. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: mojob integration 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
« no previous file with comments | « mojo/public/dart/src/data_pipe.dart ('k') | mojo/tools/mojob.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
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
4 # found in the LICENSE file.
5
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.
8 #
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
11 # to touch if we succeed. The rest are passed to the analyzer verbatim.
12
13 import os
14 import subprocess
15 import sys
16 import re
17
18 _ANALYZING_PATTERN = re.compile(r'^Analyzing \[')
19 _FINAL_REPORT_PATTERN = re.compile(r'^[0-9]+ errors and [0-9]+ warnings found.')
20
21 _NATIVE_ERROR_PATTERN = re.compile(
22 r'^\[error\] Native functions can only be declared in the SDK and code that '
23 r'is loaded through native extensions')
24 _WARNING_PATTERN = re.compile(r'^\[warning\]')
25 _THAT_ONE_BROKEN_CLOSE_IN_WEB_SOCKETS_PATTERN = re.compile(
26 r'^\[error\] The name \'close\' is already defined')
27
28 def main(args):
29 cmd = [
30 "../../third_party/dart-sdk/dart-sdk/bin/dartanalyzer",
31 ]
32
33 gen_dir = args.pop(0)
34 stamp_file = args.pop(0)
35 cmd.extend(args)
36 cmd.append("--package-root=%s" % gen_dir)
37
38 passed = True
39 try:
40 subprocess.check_output(cmd, shell=False, stderr=subprocess.STDOUT)
41 except subprocess.CalledProcessError as e:
42 # Perform post processing on the output. Filter out non-error messages and
43 # known problem patterns that we're working on.
44 raw_lines = e.output.split('\n')
45 # Remove the last empty line
46 raw_lines.pop()
47 filtered_lines = [i for i in raw_lines if (
48 not re.match(_ANALYZING_PATTERN, i) and
49 not re.match(_FINAL_REPORT_PATTERN, i) and
50 # TODO(erg): Remove the rest of these as fixes land:
51 not re.match(_WARNING_PATTERN, i) and
52 not re.match(_NATIVE_ERROR_PATTERN, i) and
53 not re.match(_THAT_ONE_BROKEN_CLOSE_IN_WEB_SOCKETS_PATTERN, i))]
54 for line in filtered_lines:
55 passed = False
56 print >> sys.stderr, line
57
58 if passed:
59 # We passed cleanly, so touch the stamp file so that we don't run again.
60 with open(stamp_file, 'a'):
61 os.utime(stamp_file, None)
62 return 0
63 else:
64 return -2
65
66 if __name__ == '__main__':
67 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « mojo/public/dart/src/data_pipe.dart ('k') | mojo/tools/mojob.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698