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 | |
| 19 | with common.temporary_file() as tempfile_path: |
Paweł Hajdan, Jr | 5647b45 | 2014-10-29 13:08:30 | [diff] [blame^] | 20 | rc = common.run_runtest(args, [ |
Paweł Hajdan, Jr | 643409b | 2014-10-23 08:34:06 | [diff] [blame] | 21 | '--annotate', 'gtest', |
| 22 | '--test-type', 'telemetry_unittests', |
Paweł Hajdan, Jr | 643409b | 2014-10-23 08:34:06 | [diff] [blame] | 23 | '--run-python-script', |
| 24 | os.path.join(common.SRC_DIR, 'tools', 'telemetry', 'run_tests'), |
| 25 | '--browser', args.build_config_fs.lower(), |
| 26 | '--retry-limit', '3', |
| 27 | '--write-full-results-to', tempfile_path, |
| 28 | ] + filter_tests) |
| 29 | |
| 30 | with open(tempfile_path) as f: |
| 31 | results = json.load(f) |
| 32 | |
Paweł Hajdan, Jr | 03ee6e03 | 2014-10-27 12:51:08 | [diff] [blame] | 33 | parsed_results = common.parse_common_test_results(results, test_separator='.') |
Paweł Hajdan, Jr | 643409b | 2014-10-23 08:34:06 | [diff] [blame] | 34 | failures = parsed_results['unexpected_failures'] |
| 35 | |
| 36 | json.dump({ |
| 37 | 'valid': bool(rc <= common.MAX_FAILURES_EXIT_STATUS and |
| 38 | ((rc == 0) or failures)), |
| 39 | 'failures': failures.keys(), |
| 40 | }, args.output) |
| 41 | |
| 42 | return rc |
| 43 | |
| 44 | |
| 45 | def main_compile_targets(args): |
| 46 | json.dump(['chrome'], args.output) |
| 47 | |
| 48 | |
| 49 | if __name__ == '__main__': |
| 50 | funcs = { |
| 51 | 'run': main_run, |
| 52 | 'compile_targets': main_compile_targets, |
| 53 | } |
| 54 | sys.exit(common.run_script(sys.argv[1:], funcs)) |