OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # Copyright 2017 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 import argparse | |
7 import json | |
8 import os | |
9 import string | |
10 import sys | |
11 | |
12 sys.path.insert( | |
13 1, | |
14 os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')) | |
15 import tracing_project | |
16 tracing_project.UpdateSysPathIfNeeded() | |
17 import vinn | |
18 | |
19 | |
20 _DISCOVER_CMDLINE = os.path.join( | |
21 os.path.dirname(__file__), '..', 'tracing', 'value', 'diagnostics', | |
22 'discover_cmdline.html') | |
23 | |
24 | |
25 def DiscoverDiagnostics(project, js_args): | |
26 res = vinn.RunFile(_DISCOVER_CMDLINE, source_paths=list(project.source_paths), | |
27 js_args=js_args) | |
28 if res.returncode != 0: | |
29 raise RuntimeError('Error running diagnostics/discover_cmdline: ' + res.stdo ut) | |
30 else: | |
31 return [str(m) for m in json.loads(res.stdout)] | |
32 | |
33 | |
34 def Main(): | |
35 project = tracing_project.TracingProject() | |
36 all_registered_diagnostics = set(DiscoverDiagnostics( | |
eakuefner
2017/06/01 21:40:48
Maybe just have DiscoverDiagnostics return a set?
| |
37 project, ['registry', '/tracing/value/diagnostics/all_diagnostics.html'])) | |
38 all_modules = list( | |
39 '/' + rel_path for rel_path in | |
40 tracing_project.TracingProject().FindAllDiagnosticsModuleRelPaths()) | |
41 all_possible_diagnostics = set(DiscoverDiagnostics( | |
42 project, ['namespace'] + all_modules)) | |
43 | |
44 unregistered_diagnostics = (all_possible_diagnostics - | |
45 all_registered_diagnostics) | |
46 if unregistered_diagnostics: | |
47 print ('These diagnostics are unregistered: %s. Please import their modules in ' | |
48 'tracing/tracing/value/diagnostics/all_diagnostics.html and ' | |
49 'ensure that they call Diagnostic.register().' % | |
50 ', '.join(unregistered_diagnostics)) | |
51 return 1 | |
52 | |
53 lowercased_diagnostics = [] | |
54 for m in all_possible_diagnostics: | |
55 if str.islower(m[0]): | |
56 lowercased_diagnostics.append(m) | |
57 if lowercased_diagnostics: | |
58 print ('These diagnostics must be renamed to start with a upper-case: %s' % | |
59 lowercased_diagnostics) | |
60 return 1 | |
61 | |
62 return 0 | |
63 | |
64 if __name__ == '__main__': | |
65 sys.exit(Main()) | |
OLD | NEW |