Paweł Hajdan, Jr | 643409b | 2014-10-23 08:34:06 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright 2014 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 | import json |
| 7 | import os |
| 8 | import sys |
| 9 | |
| 10 | |
| 11 | import common |
| 12 | |
| 13 | |
| 14 | def main_run(args): |
| 15 | filter_tests = [] |
| 16 | if args.filter_file: |
| 17 | filter_tests = json.load(args.filter_file) |
| 18 | |
jbudorick | 2f8b398b | 2015-08-14 17:50:52 | [diff] [blame] | 19 | test_args = ['--retry-limit', '3'] |
| 20 | if 'android' == args.properties.get('target_platform'): |
| 21 | test_args += ['--browser', 'android-chromium', '--device', 'android'] |
| 22 | else: |
| 23 | test_args += ['--browser', args.build_config_fs.lower()] |
nednguyen | d897d04b | 2015-10-23 13:55:52 | [diff] [blame] | 24 | test_args += ['--chrome-root', common.SRC_DIR] |
Paweł Hajdan, Jr | 643409b | 2014-10-23 08:34:06 | [diff] [blame] | 25 | with common.temporary_file() as tempfile_path: |
jbudorick | 2f8b398b | 2015-08-14 17:50:52 | [diff] [blame] | 26 | test_args += ['--write-full-results-to', tempfile_path] |
Paweł Hajdan, Jr | 5647b45 | 2014-10-29 13:08:30 | [diff] [blame] | 27 | rc = common.run_runtest(args, [ |
Paweł Hajdan, Jr | 643409b | 2014-10-23 08:34:06 | [diff] [blame] | 28 | '--test-type', 'telemetry_unittests', |
Paweł Hajdan, Jr | 643409b | 2014-10-23 08:34:06 | [diff] [blame] | 29 | '--run-python-script', |
| 30 | os.path.join(common.SRC_DIR, 'tools', 'telemetry', 'run_tests'), |
jbudorick | 2f8b398b | 2015-08-14 17:50:52 | [diff] [blame] | 31 | ] + test_args + filter_tests) |
Paweł Hajdan, Jr | 643409b | 2014-10-23 08:34:06 | [diff] [blame] | 32 | |
| 33 | with open(tempfile_path) as f: |
| 34 | results = json.load(f) |
| 35 | |
Paweł Hajdan, Jr | 03ee6e03 | 2014-10-27 12:51:08 | [diff] [blame] | 36 | parsed_results = common.parse_common_test_results(results, test_separator='.') |
Paweł Hajdan, Jr | 643409b | 2014-10-23 08:34:06 | [diff] [blame] | 37 | failures = parsed_results['unexpected_failures'] |
| 38 | |
| 39 | json.dump({ |
| 40 | 'valid': bool(rc <= common.MAX_FAILURES_EXIT_STATUS and |
| 41 | ((rc == 0) or failures)), |
| 42 | 'failures': failures.keys(), |
| 43 | }, args.output) |
| 44 | |
| 45 | return rc |
| 46 | |
| 47 | |
| 48 | def main_compile_targets(args): |
jbudorick | 3943b3b | 2015-08-14 22:22:18 | [diff] [blame] | 49 | if 'android' == args.properties.get('target_platform'): |
| 50 | json.dump(['chrome_public_apk'], args.output) |
| 51 | else: |
| 52 | json.dump(['chrome'], args.output) |
Paweł Hajdan, Jr | 643409b | 2014-10-23 08:34:06 | [diff] [blame] | 53 | |
| 54 | |
| 55 | if __name__ == '__main__': |
| 56 | funcs = { |
| 57 | 'run': main_run, |
| 58 | 'compile_targets': main_compile_targets, |
| 59 | } |
| 60 | sys.exit(common.run_script(sys.argv[1:], funcs)) |