OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import json | 6 import json |
7 import os | 7 import os |
8 import sys | 8 import sys |
9 | 9 |
10 | 10 |
11 import common | 11 import common |
12 | 12 |
13 | 13 |
14 def main_run(args): | 14 def main_run(args): |
15 filter_tests = [] | 15 typ_path = os.path.abspath(os.path.join( |
16 if args.filter_file: | 16 os.path.dirname(__file__), os.path.pardir, os.path.pardir, |
17 filter_tests = json.load(args.filter_file) | 17 'third_party', 'typ')) |
| 18 _AddToPathIfNeeded(typ_path) |
| 19 import typ |
18 | 20 |
| 21 top_level_dir = os.path.join(common.SRC_DIR, 'headless', 'lib', 'browser') |
19 with common.temporary_file() as tempfile_path: | 22 with common.temporary_file() as tempfile_path: |
20 rc = common.run_runtest(args, [ | 23 rc = typ.main( |
21 '--test-type', 'telemetry_gpu_unittests', | 24 argv=[], |
22 '--run-python-script', | 25 top_level_dir=top_level_dir, |
23 os.path.join(common.SRC_DIR, | 26 write_full_results_to=tempfile_path, |
24 'content', 'test', 'gpu', 'run_unittests.py'), | 27 coverage_source=[top_level_dir]) |
25 '--retry-limit', '3', | |
26 '--write-full-results-to', tempfile_path, | |
27 ] + filter_tests) | |
28 | 28 |
29 with open(tempfile_path) as f: | 29 with open(tempfile_path) as f: |
30 results = json.load(f) | 30 results = json.load(f) |
31 | 31 |
32 parsed_results = common.parse_common_test_results(results, test_separator='.') | 32 parsed_results = common.parse_common_test_results(results, test_separator='.') |
33 failures = parsed_results['unexpected_failures'] | 33 failures = parsed_results['unexpected_failures'] |
34 | 34 |
35 json.dump({ | 35 json.dump({ |
36 'valid': bool(rc <= common.MAX_FAILURES_EXIT_STATUS and | 36 'valid': bool(rc <= common.MAX_FAILURES_EXIT_STATUS and |
37 ((rc == 0) or failures)), | 37 ((rc == 0) or failures)), |
38 'failures': failures.keys(), | 38 'failures': failures.keys(), |
39 }, args.output) | 39 }, args.output) |
40 | 40 |
41 return rc | 41 return rc |
42 | 42 |
43 | 43 |
44 def main_compile_targets(args): | 44 def main_compile_targets(args): |
45 json.dump([], args.output) | 45 json.dump([], args.output) |
46 | 46 |
47 | 47 |
| 48 def _AddToPathIfNeeded(path): |
| 49 if path not in sys.path: |
| 50 sys.path.insert(0, path) |
| 51 |
| 52 |
48 if __name__ == '__main__': | 53 if __name__ == '__main__': |
49 funcs = { | 54 funcs = { |
50 'run': main_run, | 55 'run': main_run, |
51 'compile_targets': main_compile_targets, | 56 'compile_targets': main_compile_targets, |
52 } | 57 } |
53 sys.exit(common.run_script(sys.argv[1:], funcs)) | 58 sys.exit(common.run_script(sys.argv[1:], funcs)) |
OLD | NEW |