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