blob: 206d1b330f16d76331f13827b59daa393a662272 [file] [log] [blame]
Dirk Pranke4c9955b2021-06-16 21:13:491#!/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
8import json
9import os
10import sys
11
12
13import common
14
15
16def 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'),
22 '--isolated-script-test-output', tempfile_path
23 ], cwd=os.path.join(common.SRC_DIR, 'out', args.build_config_fs))
24
25 with open(tempfile_path) as f:
26 isolated_results = json.load(f)
27
28 results = common.parse_common_test_results(isolated_results,
29 test_separator='.')
30
Ben Pastene6de500e2021-06-29 16:25:3231 json.dump({
32 'valid': True,
33 'failures': ['%s: %s' % (k, v)
34 for k, v in results['unexpected_failures'].items()]
35 }, args.output)
Dirk Pranke4c9955b2021-06-16 21:13:4936
37 return rc
38
39
40def main_compile_targets(args):
41 json.dump([], args.output)
42
43
44if __name__ == '__main__':
45 funcs = {
46 'run': main_run,
47 'compile_targets': main_compile_targets,
48 }
49 sys.exit(common.run_script(sys.argv[1:], funcs))