blob: 2cd7cecb258b78c8cde8e090d782734c98acc4e0 [file] [log] [blame]
Takuto Ikutaa1b9cfb92022-06-06 16:30:031#!/usr/bin/env vpython3
Dirk Pranke4c9955b2021-06-16 21:13:492# 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
8import json
9import os
10import sys
11
Joshua Hood3fade1f2022-05-04 16:00:4212# Add src/testing/ into sys.path for importing common without pylint errors.
13sys.path.append(
14 os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
15from scripts import common
Dirk Pranke4c9955b2021-06-16 21:13:4916
17
18def main_run(args):
19 with common.temporary_file() as tempfile_path:
Takuto Ikutaa1b9cfb92022-06-06 16:30:0320 rc = common.run_command(['vpython3',
Dirk Pranke4c9955b2021-06-16 21:13:4921 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 Huangf4e199e2021-11-04 22:53:1124 '--isolated-script-test-output', tempfile_path,
Daniel Cheng232052152022-04-20 00:10:1125 '--skip-set-lpac-acls=1',
Dirk Pranke4c9955b2021-06-16 21:13:4926 ], 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 Pastene58c7818f2021-07-01 16:58:0734 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 Pranke4c9955b2021-06-16 21:13:4939
40 return rc
41
42
43def main_compile_targets(args):
44 json.dump([], args.output)
45
46
47if __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))