OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2016 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 argparse |
6 import json | 7 import json |
7 import sys | 8 import sys |
8 | 9 |
9 from gpu_tests import path_util | 10 from gpu_tests import path_util |
10 import gpu_project_config | 11 import gpu_project_config |
11 | 12 |
12 path_util.SetupTelemetryPaths() | 13 path_util.SetupTelemetryPaths() |
13 | 14 |
14 from telemetry.testing import browser_test_runner | 15 from telemetry.testing import browser_test_runner |
15 | 16 |
16 abbr_json_arg = '--write-abbreviated-json-results-to=' | |
17 | |
18 def PostprocessJSON(file_name): | 17 def PostprocessJSON(file_name): |
19 def TrimPrefix(s): | 18 def TrimPrefix(s): |
20 return s[1 + s.rfind('.'):] | 19 return s[1 + s.rfind('.'):] |
21 with open(file_name) as f: | 20 with open(file_name) as f: |
22 test_result = json.load(f) | 21 test_result = json.load(f) |
23 test_result['successes'] = map(TrimPrefix, test_result['successes']) | 22 test_result['successes'] = map(TrimPrefix, test_result['successes']) |
24 test_result['failures'] = map(TrimPrefix, test_result['failures']) | 23 test_result['failures'] = map(TrimPrefix, test_result['failures']) |
25 with open(file_name, 'w') as f: | 24 with open(file_name, 'w') as f: |
26 json.dump(test_result, f) | 25 json.dump(test_result, f) |
27 | 26 |
28 def main(): | 27 def main(): |
29 options = browser_test_runner.TestRunOptions() | 28 options = browser_test_runner.TestRunOptions() |
30 rest_args = sys.argv[1:] | 29 rest_args = sys.argv[1:] |
31 retval = browser_test_runner.Run( | 30 retval = browser_test_runner.Run( |
32 gpu_project_config.CONFIG, options, rest_args) | 31 gpu_project_config.CONFIG, options, rest_args) |
33 # Postprocess the outputted JSON to trim all of the prefixes from | 32 # Postprocess the outputted JSON to trim all of the prefixes from |
34 # the test names, to keep them as similar to the old form as | 33 # the test names, to keep them as similar to the old form as |
35 # possible -- and keep them from getting crazily long. | 34 # possible -- and keep them from getting crazily long. |
36 for arg in rest_args: | 35 parser = argparse.ArgumentParser(description='Temporary argument parser') |
37 if arg.startswith(abbr_json_arg): | 36 parser.add_argument( |
38 PostprocessJSON(arg[len(abbr_json_arg):]) | 37 '--write-abbreviated-json-results-to', metavar='FILENAME', |
39 break | 38 action='store', |
| 39 help=('Full path for json results')) |
| 40 option, _ = parser.parse_known_args(rest_args) |
| 41 if option.write_abbreviated_json_results_to: |
| 42 PostprocessJSON(option.write_abbreviated_json_results_to) |
40 | 43 |
41 if __name__ == '__main__': | 44 if __name__ == '__main__': |
42 sys.exit(main()) | 45 sys.exit(main()) |
OLD | NEW |