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'), |
Kuan Huang | f4e199e | 2021-11-04 22:53:11 | [diff] [blame^] | 22 | '--isolated-script-test-output', tempfile_path, |
| 23 | '--skip-set-lpac-acls=1', |
Dirk Pranke | 4c9955b | 2021-06-16 21:13:49 | [diff] [blame] | 24 | ], cwd=os.path.join(common.SRC_DIR, 'out', args.build_config_fs)) |
| 25 | |
| 26 | with open(tempfile_path) as f: |
| 27 | isolated_results = json.load(f) |
| 28 | |
| 29 | results = common.parse_common_test_results(isolated_results, |
| 30 | test_separator='.') |
| 31 | |
Ben Pastene | 58c7818f | 2021-07-01 16:58:07 | [diff] [blame] | 32 | failures = [ |
| 33 | '%s: %s' % (k, v) for k, v in results['unexpected_failures'].items() |
| 34 | ] |
| 35 | common.record_local_script_results( |
| 36 | 'metrics_python_tests', args.output, failures, True) |
Dirk Pranke | 4c9955b | 2021-06-16 21:13:49 | [diff] [blame] | 37 | |
| 38 | return rc |
| 39 | |
| 40 | |
| 41 | def main_compile_targets(args): |
| 42 | json.dump([], args.output) |
| 43 | |
| 44 | |
| 45 | if __name__ == '__main__': |
| 46 | funcs = { |
| 47 | 'run': main_run, |
| 48 | 'compile_targets': main_compile_targets, |
| 49 | } |
| 50 | sys.exit(common.run_script(sys.argv[1:], funcs)) |