Dirk Pranke | 4c9955b | 2021-06-16 21:13:49 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 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 | |
| 6 | """Runs //tools/metrics/metrics_python_tests.py as a 'script' test.""" |
| 7 | |
| 8 | import json |
| 9 | import os |
| 10 | import sys |
| 11 | |
| 12 | |
| 13 | import common |
| 14 | |
| 15 | |
| 16 | def main_run(args): |
| 17 | with common.temporary_file() as tempfile_path: |
| 18 | rc = common.run_command(['vpython', |
| 19 | os.path.join(common.SRC_DIR, 'testing', 'test_env.py'), |
| 20 | os.path.join(common.SRC_DIR, 'tools', 'metrics', |
| 21 | 'metrics_python_tests.py'), |
| 22 | '--isolated-script-test-output', tempfile_path |
| 23 | ], cwd=os.path.join(common.SRC_DIR, 'out', args.build_config_fs)) |
| 24 | |
| 25 | with open(tempfile_path) as f: |
| 26 | isolated_results = json.load(f) |
| 27 | |
| 28 | results = common.parse_common_test_results(isolated_results, |
| 29 | test_separator='.') |
| 30 | |
Ben Pastene | 6de500e | 2021-06-29 16:25:32 | [diff] [blame] | 31 | json.dump({ |
| 32 | 'valid': True, |
| 33 | 'failures': ['%s: %s' % (k, v) |
| 34 | for k, v in results['unexpected_failures'].items()] |
| 35 | }, args.output) |
Dirk Pranke | 4c9955b | 2021-06-16 21:13:49 | [diff] [blame] | 36 | |
| 37 | return rc |
| 38 | |
| 39 | |
| 40 | def main_compile_targets(args): |
| 41 | json.dump([], args.output) |
| 42 | |
| 43 | |
| 44 | if __name__ == '__main__': |
| 45 | funcs = { |
| 46 | 'run': main_run, |
| 47 | 'compile_targets': main_compile_targets, |
| 48 | } |
| 49 | sys.exit(common.run_script(sys.argv[1:], funcs)) |