| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2015 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 """See README.md for usage instructions. | 6 """See README.md for usage instructions. |
| 7 | 7 |
| 8 This file heavily modified from build/scripts/slave/gtest_slave_utils.py and | 8 This file heavily modified from build/scripts/slave/gtest_slave_utils.py and |
| 9 is intended to replace it as all tests move to swarming. | 9 is intended to replace it as all tests move to swarming. |
| 10 TODO(estaab): Remove build/scripts/slave/gtest.* once this is fully deployed. | 10 TODO(estaab): Remove build/scripts/slave/gtest.* once this is fully deployed. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 generator = JSONResultsGenerator( | 73 generator = JSONResultsGenerator( |
| 74 builder_name, build_number, | 74 builder_name, build_number, |
| 75 results_directory, | 75 results_directory, |
| 76 test_results_map, | 76 test_results_map, |
| 77 svn_revisions=[('chromium', chrome_revision)], | 77 svn_revisions=[('chromium', chrome_revision)], |
| 78 master_name=master_name) | 78 master_name=master_name) |
| 79 generator.generate_json_output() | 79 generator.generate_json_output() |
| 80 generator.generate_times_ms_file() | 80 generator.generate_times_ms_file() |
| 81 | 81 |
| 82 | 82 |
| 83 def generate_files_for_gtest_results( |
| 84 raw_json, builder_name, build_number, results_directory, chrome_revision, |
| 85 master_name): |
| 86 results_map = get_results_map_from_json(raw_json) |
| 87 generate_json_results(results_map, builder_name, |
| 88 build_number, results_directory, |
| 89 chrome_revision, master_name) |
| 90 files = [(f, os.path.join(results_directory, f)) for f in |
| 91 (FULL_RESULTS_FILENAME, TIMES_MS_FILENAME)] |
| 92 return files |
| 93 |
| 94 |
| 83 def main(): | 95 def main(): |
| 84 option_parser = optparse.OptionParser() | 96 option_parser = optparse.OptionParser() |
| 85 option_parser.add_option('--test-type', | 97 option_parser.add_option('--test-type', |
| 86 help='Test type that generated the results json,' | 98 help='Test type that generated the results json,' |
| 87 ' e.g. unit-tests.') | 99 ' e.g. unit-tests.') |
| 88 option_parser.add_option('--results-directory', default=os.getcwd(), | 100 option_parser.add_option('--results-directory', default=os.getcwd(), |
| 89 help='Output results directory source dir.') | 101 help='Output results directory source dir.') |
| 90 option_parser.add_option('--input-gtest-json', | 102 option_parser.add_option('--input-json', |
| 91 help='Test results json file (input for us).') | 103 help='Test results json file (input for us).') |
| 92 option_parser.add_option('--builder-name', | 104 option_parser.add_option('--builder-name', |
| 93 default='DUMMY_BUILDER_NAME', | 105 default='DUMMY_BUILDER_NAME', |
| 94 help='The name of the builder shown on the ' | 106 help='The name of the builder shown on the ' |
| 95 'waterfall running this script e.g. WebKit.') | 107 'waterfall running this script e.g. WebKit.') |
| 96 option_parser.add_option('--build-number', | 108 option_parser.add_option('--build-number', |
| 97 help='The build number of the builder running' | 109 help='The build number of the builder running' |
| 98 'this script.') | 110 'this script.') |
| 99 option_parser.add_option('--test-results-server', | 111 option_parser.add_option('--test-results-server', |
| 100 help='The test results server to upload the ' | 112 help='The test results server to upload the ' |
| 101 'results.') | 113 'results.') |
| 102 option_parser.add_option('--master-name', | 114 option_parser.add_option('--master-name', |
| 103 help='The name of the buildbot master. ' | 115 help='The name of the buildbot master. ' |
| 104 'Both test-results-server and master-name ' | 116 'Both test-results-server and master-name ' |
| 105 'need to be specified to upload the results ' | 117 'need to be specified to upload the results ' |
| 106 'to the server.') | 118 'to the server.') |
| 107 option_parser.add_option('--chrome-revision', default='0', | 119 option_parser.add_option('--chrome-revision', default='0', |
| 108 help='The Chromium revision being tested. If not ' | 120 help='The Chromium revision being tested. If not ' |
| 109 'given, defaults to 0.') | 121 'given, defaults to 0.') |
| 110 | 122 |
| 111 options = option_parser.parse_args()[0] | 123 options = option_parser.parse_args()[0] |
| 112 logging.basicConfig() | 124 logging.basicConfig() |
| 113 | 125 |
| 114 if not options.test_type: | 126 if not options.test_type: |
| 115 option_parser.error('--test-type needs to be specified.') | 127 option_parser.error('--test-type needs to be specified.') |
| 116 return 1 | 128 return 1 |
| 117 | 129 |
| 118 if not options.input_gtest_json: | 130 if not options.input_json: |
| 119 option_parser.error('--input-gtest-json needs to be specified.') | 131 option_parser.error('--input-gtest-json needs to be specified.') |
| 120 return 1 | 132 return 1 |
| 121 | 133 |
| 122 if options.test_results_server and not options.master_name: | 134 if options.test_results_server and not options.master_name: |
| 123 logging.warn('--test-results-server is given but ' | 135 logging.warn('--test-results-server is given but ' |
| 124 '--master-name is not specified; the results won\'t be ' | 136 '--master-name is not specified; the results won\'t be ' |
| 125 'uploaded to the server.') | 137 'uploaded to the server.') |
| 126 | 138 |
| 127 with file(options.input_gtest_json) as json_file: | 139 with file(options.input_json) as json_file: |
| 128 results_map = get_results_map_from_json(json_file.read()) | 140 raw_json = json_file.read() |
| 129 | 141 |
| 130 generate_json_results(results_map, options.builder_name, | 142 if (raw_json.get(json_results_generator.JSONResultsGenerator.VERSION, 0) != |
| 131 options.build_number, options.results_directory, | 143 json_results_generator.JSONResultsGenerator.VERSION_NUMBER): |
| 132 options.chrome_revision, options.master_name) | 144 files = generate_files_for_gtest_results( |
| 145 raw_json, builder_name=options.builder_name, |
| 146 build_number=options.build_number, |
| 147 results_directory=options.results_directory, |
| 148 chrome_revision=options.chrome_revision, |
| 149 master_name=options.master_name) |
| 150 else: |
| 151 files = [options.input_json] |
| 152 |
| 133 | 153 |
| 134 # Upload to a test results server if specified. | 154 # Upload to a test results server if specified. |
| 135 if options.test_results_server and options.master_name: | 155 if options.test_results_server and options.master_name: |
| 136 print 'Uploading JSON files for builder "%s" to server "%s"' % ( | 156 print 'Uploading JSON files for builder "%s" to server "%s"' % ( |
| 137 options.builder_name, options.test_results_server) | 157 options.builder_name, options.test_results_server) |
| 138 attrs = [('builder', options.builder_name), | 158 attrs = [('builder', options.builder_name), |
| 139 ('testtype', options.test_type), | 159 ('testtype', options.test_type), |
| 140 ('master', options.master_name)] | 160 ('master', options.master_name)] |
| 141 | 161 |
| 142 files = [(f, os.path.join(options.results_directory, f)) for f in | |
| 143 (FULL_RESULTS_FILENAME, TIMES_MS_FILENAME)] | |
| 144 | |
| 145 # Set uploading timeout in case appengine server is having problem. | 162 # Set uploading timeout in case appengine server is having problem. |
| 146 # 120 seconds are more than enough to upload test results. | 163 # 120 seconds are more than enough to upload test results. |
| 147 test_results_uploader.upload_test_results( | 164 test_results_uploader.upload_test_results( |
| 148 options.test_results_server, attrs, files, 120) | 165 options.test_results_server, attrs, files, 120) |
| 149 return 0 | 166 return 0 |
| 150 | 167 |
| 151 | 168 |
| 152 if __name__ == '__main__': | 169 if __name__ == '__main__': |
| 153 sys.exit(main()) | 170 sys.exit(main()) |
| OLD | NEW |