Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import json | 5 import json |
| 6 | 6 |
| 7 from recipe_engine.config import List | 7 from recipe_engine.config import List |
| 8 from recipe_engine.config import Single | 8 from recipe_engine.config import Single |
| 9 from recipe_engine.recipe_api import Property | 9 from recipe_engine.recipe_api import Property |
| 10 | 10 |
| 11 | 11 |
| 12 DEPS = [ | 12 DEPS = [ |
| 13 'chromium', | 13 'chromium', |
| 14 'chromium_tests', | 14 'chromium_tests', |
| 15 'findit', | 15 'findit', |
| 16 'gclient', | 16 'gclient', |
| 17 'recipe_engine/json', | 17 'recipe_engine/json', |
| 18 'recipe_engine/path', | 18 'recipe_engine/path', |
| 19 'recipe_engine/properties', | 19 'recipe_engine/properties', |
| 20 'recipe_engine/python', | 20 'recipe_engine/python', |
| 21 'recipe_engine/step', | 21 'recipe_engine/step', |
| 22 ] | 22 ] |
| 23 | 23 |
| 24 | 24 |
| 25 PROPERTIES = { | 25 PROPERTIES = { |
| 26 'target_mastername': Property( | 26 'target_mastername': Property( |
| 27 kind=str, help='The target master to match compile config to.'), | 27 kind=str, help='The target master to match compile config to.'), |
| 28 'target_buildername': Property( | 28 'target_buildername': Property( |
| 29 kind=str, help='The target builder to match compile config to.'), | 29 kind=str, help='The target builder to match compile config to.'), |
| 30 'good_revision': Property( | 30 'good_revision': Property( |
| 31 kind=str, help='The last known good chromium revision.'), | 31 kind=str, help='The last known good chromium revision.'), |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 45 PASSED = 'passed' # Compile passed. | 45 PASSED = 'passed' # Compile passed. |
| 46 FAILED = 'failed' # Compile failed. | 46 FAILED = 'failed' # Compile failed. |
| 47 | 47 |
| 48 | 48 |
| 49 def _run_compile_at_revision(api, target_mastername, target_buildername, | 49 def _run_compile_at_revision(api, target_mastername, target_buildername, |
| 50 revision, compile_targets, use_analyze): | 50 revision, compile_targets, use_analyze): |
| 51 with api.step.nest('test %s' % str(revision)): | 51 with api.step.nest('test %s' % str(revision)): |
| 52 # Checkout code at the given revision to recompile. | 52 # Checkout code at the given revision to recompile. |
| 53 bot_config = api.chromium_tests.create_bot_config_object( | 53 bot_config = api.chromium_tests.create_bot_config_object( |
| 54 target_mastername, target_buildername) | 54 target_mastername, target_buildername) |
| 55 bot_update_step, bot_db = \ | 55 bot_update_step, bot_db = api.chromium_tests.prepare_checkout( |
| 56 api.chromium_tests.prepare_checkout( | 56 bot_config, root_solution_revision=revision) |
| 57 bot_config, | |
| 58 root_solution_revision=revision) | |
| 59 | 57 |
| 60 # TODO(http://crbug.com/560991): if compile targets are provided, check | 58 # TODO(http://crbug.com/560991): if compile targets are provided, check |
| 61 # whether they exist and then use analyze to compile the impacted ones by | 59 # whether they exist and then use analyze to compile the impacted ones by |
| 62 # the given revision. | 60 # the given revision. |
| 63 compile_targets = sorted(set(compile_targets or [])) | 61 compile_targets = sorted(set(compile_targets or [])) |
| 64 if not compile_targets: | 62 if not compile_targets: |
| 65 _, tests_including_triggered = api.chromium_tests.get_tests( | 63 _, tests_including_triggered = api.chromium_tests.get_tests( |
| 66 bot_config, bot_db) | 64 bot_config, bot_db) |
| 67 compile_targets = api.chromium_tests.get_compile_targets( | 65 compile_targets = api.chromium_tests.get_compile_targets( |
| 68 bot_config, bot_db, tests_including_triggered) | 66 bot_config, bot_db, tests_including_triggered) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 target_mastername, target_buildername) | 105 target_mastername, target_buildername) |
| 108 api.chromium_tests.configure_build( | 106 api.chromium_tests.configure_build( |
| 109 bot_config, override_bot_type='builder_tester') | 107 bot_config, override_bot_type='builder_tester') |
| 110 | 108 |
| 111 # Sync to bad revision, and retrieve revisions in the regression range. | 109 # Sync to bad revision, and retrieve revisions in the regression range. |
| 112 api.chromium_tests.prepare_checkout( | 110 api.chromium_tests.prepare_checkout( |
| 113 bot_config, | 111 bot_config, |
| 114 root_solution_revision=bad_revision) | 112 root_solution_revision=bad_revision) |
| 115 revisions_to_check = api.findit.revisions_between(good_revision, bad_revision) | 113 revisions_to_check = api.findit.revisions_between(good_revision, bad_revision) |
| 116 | 114 |
| 117 results = [] | 115 compile_results = {} |
| 116 try_job_metadata = { | |
| 117 'regression_range_size': len(revisions_to_check) | |
| 118 } | |
| 119 report = { | |
| 120 'result': compile_results, | |
| 121 'metadata': try_job_metadata, | |
| 122 } | |
| 123 | |
| 118 try: | 124 try: |
| 119 for current_revision in revisions_to_check: | 125 for current_revision in revisions_to_check: |
| 126 last_revision = None | |
| 127 last_result = None | |
| 120 compile_result = _run_compile_at_revision( | 128 compile_result = _run_compile_at_revision( |
| 121 api, target_mastername, target_buildername, | 129 api, target_mastername, target_buildername, |
| 122 current_revision, requested_compile_targets, use_analyze) | 130 current_revision, requested_compile_targets, use_analyze) |
| 123 | 131 |
| 124 results.append([current_revision, compile_result]) | 132 compile_results[current_revision] = compile_result |
| 133 last_revision = current_revision | |
| 134 last_result = compile_result | |
|
stgao
2016/01/29 16:48:25
We don't have to save the ``last_result``, right?
lijeffrey
2016/01/29 20:02:41
Done.
| |
| 125 if compile_result == CompileResult.FAILED: | 135 if compile_result == CompileResult.FAILED: |
| 126 # TODO(http://crbug.com/560991): if compile targets are specified, | 136 # TODO(http://crbug.com/560991): if compile targets are specified, |
| 127 # compile may fail because those targets are added in a later revision. | 137 # compile may fail because those targets are added in a later revision. |
| 128 break # Found the culprit, no need to check later revisions. | 138 break # Found the culprit, no need to check later revisions. |
| 129 finally: | 139 finally: |
| 130 # Report the result. | 140 # Report the result. |
| 131 # TODO(http://crbug.com/563807): use api.python.succeeding_step instead. | 141 # TODO(http://crbug.com/563807): use api.python.succeeding_step instead. |
| 132 step_result = api.python.inline( | 142 step_result = api.python.inline( |
| 133 'report', 'import sys; sys.exit(0)', add_python_log=False) | 143 'report', 'import sys; sys.exit(0)', add_python_log=False) |
| 134 if (not requested_compile_targets and | 144 if (not requested_compile_targets and |
| 135 results and results[-1][1] == CompileResult.FAILED): | 145 compile_results and |
| 136 step_result.presentation.step_text = '<br/>Culprit: %s' % results[-1][0] | 146 last_revision and |
| 147 last_result == CompileResult.FAILED): | |
| 148 step_result.presentation.step_text = ( | |
| 149 '<br/>Culprit: %s' % last_revision) | |
| 137 step_result.presentation.logs.setdefault('result', []).append( | 150 step_result.presentation.logs.setdefault('result', []).append( |
| 138 json.dumps(results, indent=2)) | 151 json.dumps(report, indent=2)) |
| 139 | 152 |
| 140 # Set the result as a build property too, so that it will be reported back | 153 # Set the result as a build property too, so that it will be reported back |
| 141 # to Buildbucket and Findit will pull from there instead of buildbot master. | 154 # to Buildbucket and Findit will pull from there instead of buildbot master. |
| 142 step_result.presentation.properties['result'] = results | 155 step_result.presentation.properties['result'] = report |
| 143 | 156 |
| 144 return results | 157 return report |
| 145 | 158 |
| 146 | 159 |
| 147 def GenTests(api): | 160 def GenTests(api): |
| 148 def props(compile_targets=None, use_analyze=False): | 161 def props(compile_targets=None, use_analyze=False): |
| 149 properties = { | 162 properties = { |
| 150 'mastername': 'tryserver.chromium.linux', | 163 'mastername': 'tryserver.chromium.linux', |
| 151 'buildername': 'linux_variable', | 164 'buildername': 'linux_variable', |
| 152 'slavename': 'build1-a1', | 165 'slavename': 'build1-a1', |
| 153 'buildnumber': '1', | 166 'buildnumber': '1', |
| 154 'target_mastername': 'chromium.linux', | 167 'target_mastername': 'chromium.linux', |
| 155 'target_buildername': 'Linux Builder', | 168 'target_buildername': 'Linux Builder', |
| 156 'good_revision': 'r0', | 169 'good_revision': 'r0', |
| 157 'bad_revision': 'r1', | 170 'bad_revision': 'r1', |
| 158 'use_analyze': use_analyze, | 171 'use_analyze': use_analyze, |
| 159 } | 172 } |
| 160 if compile_targets: | 173 if compile_targets: |
| 161 properties['compile_targets'] = compile_targets | 174 properties['compile_targets'] = compile_targets |
| 162 return api.properties(**properties) | 175 return api.properties(**properties) |
| 163 | 176 |
| 164 yield ( | 177 yield ( |
| 165 api.test('compile_specified_targets') + | 178 api.test('compile_specified_targets') + |
| 166 props(compile_targets=['target_name']) | 179 props(compile_targets=['target_name']) |
| 167 ) | 180 ) |
| 168 | 181 |
| 169 yield ( | 182 yield ( |
| 170 api.test('compile_default_targets') + | 183 api.test('compile_default_targets') + |
| 171 props() + | 184 props() + |
| 172 api.override_step_data('test r1.read test spec', | 185 api.override_step_data('test r1.read test spec', |
| 173 api.json.output({ | 186 api.json.output({ |
| 174 'Linux Builder': { | 187 'Linux Builder': { |
| 175 'additional_compile_targets': [ | 188 'additional_compile_targets': [ |
| 176 'base_unittests', | 189 'base_unittests', |
| 177 ], | 190 ], |
| 178 } | 191 } |
| 179 })) | 192 })) |
| 180 ) | 193 ) |
| 181 | 194 |
| 182 yield ( | 195 yield ( |
| 183 api.test('compile_succeeded') + | 196 api.test('compile_succeeded') + |
| 184 props() + | 197 props() + |
| 185 api.override_step_data('test r1.compile', retcode=1) | 198 api.override_step_data('test r1.compile', retcode=1) |
| 186 ) | 199 ) |
| 187 | 200 |
| 188 yield ( | 201 yield ( |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 219 'test_targets': [], | 232 'test_targets': [], |
| 220 }) | 233 }) |
| 221 ) | 234 ) |
| 222 ) | 235 ) |
| 223 | 236 |
| 224 yield ( | 237 yield ( |
| 225 api.test('compile_affected_targets_only') + | 238 api.test('compile_affected_targets_only') + |
| 226 props(use_analyze=True) + | 239 props(use_analyze=True) + |
| 227 api.override_step_data('test r1.read test spec', | 240 api.override_step_data('test r1.read test spec', |
| 228 api.json.output({ | 241 api.json.output({ |
| 229 'Linux Builder': { | 242 'Linux Builder': { |
| 230 'additional_compile_targets': [ | 243 'additional_compile_targets': [ |
| 231 'a', 'a_run', | 244 'a', 'a_run', |
| 232 'b', 'b_run', | 245 'b', 'b_run', |
| 233 ], | 246 ], |
| 234 } | 247 } |
| 235 })) + | 248 })) + |
| 236 api.override_step_data( | 249 api.override_step_data( |
| 237 'test r1.analyze', | 250 'test r1.analyze', |
| 238 api.json.output({ | 251 api.json.output({ |
| 239 'status': 'Found dependency', | 252 'status': 'Found dependency', |
| 240 'compile_targets': ['a', 'a_run'], | 253 'compile_targets': ['a', 'a_run'], |
| 241 'test_targets': ['a', 'a_run'], | 254 'test_targets': ['a', 'a_run'], |
| 242 }) | 255 }) |
| 243 ) | 256 ) |
| 244 ) | 257 ) |
| OLD | NEW |