check_network_annotations.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. """//testing/scripts wrapper for the network traffic annotations checks.
  6. This script is used to run check_annotations.py on the trybots to ensure that
  7. all network traffic annotations have correct syntax and semantics, and all
  8. functions requiring annotations have one.
  9. This is a wrapper around tools/traffic_annotation/scripts/auditor.py.
  10. See tools/traffic_annotation/scripts/auditor/README.md for instructions on
  11. running locally."""
  12. import json
  13. import os
  14. import sys
  15. # Add src/testing/ into sys.path for importing common without pylint errors.
  16. sys.path.append(
  17. os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
  18. from scripts import common
  19. def main_run(args):
  20. command_line = [
  21. sys.executable,
  22. os.path.join(common.SRC_DIR, 'tools', 'traffic_annotation', 'scripts',
  23. 'check_annotations.py'),
  24. '--build-path',
  25. os.path.join(args.paths['checkout'], 'out', args.build_config_fs),
  26. ]
  27. rc = common.run_command(command_line)
  28. failures = ['Please refer to stdout for errors.'] if rc else []
  29. common.record_local_script_results(
  30. 'check_network_annotations', args.output, failures, True)
  31. return rc
  32. def main_compile_targets(args):
  33. json.dump(['traffic_annotation_auditor_dependencies'], args.output)
  34. if __name__ == '__main__':
  35. funcs = {
  36. 'run': main_run,
  37. 'compile_targets': main_compile_targets,
  38. }
  39. sys.exit(common.run_script(sys.argv[1:], funcs))