metrics_python_tests.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env vpython3
  2. # Copyright 2021 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. """Runs //tools/metrics/metrics_python_tests.py as a 'script' test."""
  6. import json
  7. import os
  8. import sys
  9. # Add src/testing/ into sys.path for importing common without pylint errors.
  10. sys.path.append(
  11. os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
  12. from scripts import common
  13. def main_run(args):
  14. with common.temporary_file() as tempfile_path:
  15. rc = common.run_command(['vpython3',
  16. os.path.join(common.SRC_DIR, 'testing', 'test_env.py'),
  17. os.path.join(common.SRC_DIR, 'tools', 'metrics',
  18. 'metrics_python_tests.py'),
  19. '--isolated-script-test-output', tempfile_path,
  20. '--skip-set-lpac-acls=1',
  21. ], cwd=os.path.join(common.SRC_DIR, 'out', args.build_config_fs))
  22. with open(tempfile_path) as f:
  23. isolated_results = json.load(f)
  24. results = common.parse_common_test_results(isolated_results,
  25. test_separator='.')
  26. failures = [
  27. '%s: %s' % (k, v) for k, v in results['unexpected_failures'].items()
  28. ]
  29. common.record_local_script_results(
  30. 'metrics_python_tests', args.output, failures, True)
  31. return rc
  32. def main_compile_targets(args):
  33. json.dump([], 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))