1#!/usr/bin/env vpython3 2# Copyright 2021 The Chromium Authors 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 12# 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 16 17 18def main_run(args): 19 with common.temporary_file() as tempfile_path: 20 rc = common.run_command(['vpython3', 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'), 24 '--isolated-script-test-output', tempfile_path, 25 '--skip-set-lpac-acls=1', 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 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) 39 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)) 53