Takuto Ikuta | a1b9cfb9 | 2022-06-06 16:30:03 | [diff] [blame] | 1 | #!/usr/bin/env vpython3 |
Dirk Pranke | 4c9955b | 2021-06-16 21:13:49 | [diff] [blame] | 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 | |
Joshua Hood | 3fade1f | 2022-05-04 16:00:42 | [diff] [blame] | 12 | # Add src/testing/ into sys.path for importing common without pylint errors. |
| 13 | sys.path.append( |
| 14 | os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))) |
| 15 | from scripts import common |
Dirk Pranke | 4c9955b | 2021-06-16 21:13:49 | [diff] [blame] | 16 | |
| 17 | |
| 18 | def main_run(args): |
| 19 | with common.temporary_file() as tempfile_path: |
Takuto Ikuta | a1b9cfb9 | 2022-06-06 16:30:03 | [diff] [blame] | 20 | rc = common.run_command(['vpython3', |
Dirk Pranke | 4c9955b | 2021-06-16 21:13:49 | [diff] [blame] | 21 | os.path.join(common.SRC_DIR, 'testing', 'test_env.py'), |
| 22 | os.path.join(common.SRC_DIR, 'tools', 'metrics', |
| 23 | 'metrics_python_tests.py'), |
Kuan Huang | f4e199e | 2021-11-04 22:53:11 | [diff] [blame] | 24 | '--isolated-script-test-output', tempfile_path, |
Daniel Cheng | 23205215 | 2022-04-20 00:10:11 | [diff] [blame] | 25 | '--skip-set-lpac-acls=1', |
Dirk Pranke | 4c9955b | 2021-06-16 21:13:49 | [diff] [blame] | 26 | ], cwd=os.path.join(common.SRC_DIR, 'out', args.build_config_fs)) |
| 27 | |
| 28 | with open(tempfile_path) as f: |
| 29 | isolated_results = json.load(f) |
| 30 | |
| 31 | results = common.parse_common_test_results(isolated_results, |
| 32 | test_separator='.') |
| 33 | |
Ben Pastene | 58c7818f | 2021-07-01 16:58:07 | [diff] [blame] | 34 | failures = [ |
| 35 | '%s: %s' % (k, v) for k, v in results['unexpected_failures'].items() |
| 36 | ] |
| 37 | common.record_local_script_results( |
| 38 | 'metrics_python_tests', args.output, failures, True) |
Dirk Pranke | 4c9955b | 2021-06-16 21:13:49 | [diff] [blame] | 39 | |
| 40 | return rc |
| 41 | |
| 42 | |
| 43 | def main_compile_targets(args): |
| 44 | json.dump([], args.output) |
| 45 | |
| 46 | |
| 47 | if __name__ == '__main__': |
| 48 | funcs = { |
| 49 | 'run': main_run, |
| 50 | 'compile_targets': main_compile_targets, |
| 51 | } |
| 52 | sys.exit(common.run_script(sys.argv[1:], funcs)) |