| Index: tracing/bin/validate_all_diagnostics
|
| diff --git a/tracing/bin/validate_all_diagnostics b/tracing/bin/validate_all_diagnostics
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..16fa8bb9a91dc81a680d310a93f809dce08791cf
|
| --- /dev/null
|
| +++ b/tracing/bin/validate_all_diagnostics
|
| @@ -0,0 +1,65 @@
|
| +#!/usr/bin/env python
|
| +# Copyright 2017 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +import argparse
|
| +import json
|
| +import os
|
| +import string
|
| +import sys
|
| +
|
| +sys.path.insert(
|
| + 1,
|
| + os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))
|
| +import tracing_project
|
| +tracing_project.UpdateSysPathIfNeeded()
|
| +import vinn
|
| +
|
| +
|
| +_DISCOVER_CMDLINE = os.path.join(
|
| + os.path.dirname(__file__), '..', 'tracing', 'value', 'diagnostics',
|
| + 'discover_cmdline.html')
|
| +
|
| +
|
| +def DiscoverDiagnostics(project, js_args):
|
| + res = vinn.RunFile(_DISCOVER_CMDLINE, source_paths=list(project.source_paths),
|
| + js_args=js_args)
|
| + if res.returncode != 0:
|
| + raise RuntimeError('Error running diagnostics/discover_cmdline: ' + res.stdout)
|
| + else:
|
| + return set([str(m) for m in json.loads(res.stdout)])
|
| +
|
| +
|
| +def Main():
|
| + project = tracing_project.TracingProject()
|
| + all_registered_diagnostics = DiscoverDiagnostics(
|
| + project, ['registry', '/tracing/value/diagnostics/all_diagnostics.html'])
|
| + all_modules = list(
|
| + '/' + rel_path for rel_path in
|
| + tracing_project.TracingProject().FindAllDiagnosticsModuleRelPaths())
|
| + all_possible_diagnostics = DiscoverDiagnostics(
|
| + project, ['namespace'] + all_modules)
|
| +
|
| + unregistered_diagnostics = (all_possible_diagnostics -
|
| + all_registered_diagnostics)
|
| + if unregistered_diagnostics:
|
| + print ('These diagnostics are unregistered: %s. Please import their modules in '
|
| + 'tracing/tracing/value/diagnostics/all_diagnostics.html and '
|
| + 'ensure that they call Diagnostic.register().' %
|
| + ', '.join(unregistered_diagnostics))
|
| + return 1
|
| +
|
| + lowercased_diagnostics = []
|
| + for m in all_possible_diagnostics:
|
| + if str.islower(m[0]):
|
| + lowercased_diagnostics.append(m)
|
| + if lowercased_diagnostics:
|
| + print ('These diagnostics must be renamed to start with a upper-case: %s' %
|
| + lowercased_diagnostics)
|
| + return 1
|
| +
|
| + return 0
|
| +
|
| +if __name__ == '__main__':
|
| + sys.exit(Main())
|
|
|