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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 try: | 116 try: |
| 119 for current_revision in revisions_to_check: | 117 for current_revision in revisions_to_check: |
| 120 compile_result = _run_compile_at_revision( | 118 compile_result = _run_compile_at_revision( |
| 121 api, target_mastername, target_buildername, | 119 api, target_mastername, target_buildername, |
| 122 current_revision, requested_compile_targets, use_analyze) | 120 current_revision, requested_compile_targets, use_analyze) |
| 123 | 121 |
| 124 results.append([current_revision, compile_result]) | 122 results.append([current_revision, compile_result]) |
| 125 if compile_result == CompileResult.FAILED: | 123 if compile_result == CompileResult.FAILED: |
| 126 # TODO(http://crbug.com/560991): if compile targets are specified, | 124 # TODO(http://crbug.com/560991): if compile targets are specified, |
| 127 # compile may fail because those targets are added in a later revision. | 125 # compile may fail because those targets are added in a later revision. |
| 128 break # Found the culprit, no need to check later revisions. | 126 break # Found the culprit, no need to check later revisions. |
| 129 finally: | 127 finally: |
| 130 # Report the result. | 128 # Report the result. |
| 131 # TODO(http://crbug.com/563807): use api.python.succeeding_step instead. | 129 # TODO(http://crbug.com/563807): use api.python.succeeding_step instead. |
| 132 step_result = api.python.inline( | 130 step_result = api.python.inline( |
| 133 'report', 'import sys; sys.exit(0)', add_python_log=False) | 131 'report', 'import sys; sys.exit(0)', add_python_log=False) |
| 134 if (not requested_compile_targets and | 132 if (not requested_compile_targets and |
| 135 results and results[-1][1] == CompileResult.FAILED): | 133 results and results[-1][1] == CompileResult.FAILED): |
| 136 step_result.presentation.step_text = '<br/>Culprit: %s' % results[-1][0] | 134 step_result.presentation.step_text = '<br/>Culprit: %s' % results[-1][0] |
| 137 step_result.presentation.logs.setdefault('result', []).append( | 135 step_result.presentation.logs.setdefault('result', []).append( |
| 138 json.dumps(results, indent=2)) | 136 json.dumps(results, indent=2)) |
| 139 | 137 |
| 140 # Set the result as a build property too, so that it will be reported back | 138 # 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. | 139 # to Buildbucket and Findit will pull from there instead of buildbot master. |
| 142 step_result.presentation.properties['result'] = results | 140 step_result.presentation.properties['result'] = results |
| 141 step_result.presentation.properties['number_of_commits_in_range'] = len( | |
|
stgao
2016/01/25 22:21:35
As discussed offline, we'd better not add a new bu
lijeffrey
2016/01/29 09:53:42
Done.
| |
| 142 revisions_to_check) | |
|
chanli
2016/01/22 18:05:27
I think this number is actually len(failure_info['
lijeffrey
2016/01/22 22:26:43
I think you're right, it should be the same. In th
| |
| 143 | 143 |
| 144 return results | 144 return results |
| 145 | 145 |
| 146 | 146 |
| 147 def GenTests(api): | 147 def GenTests(api): |
| 148 def props(compile_targets=None, use_analyze=False): | 148 def props(compile_targets=None, use_analyze=False): |
| 149 properties = { | 149 properties = { |
| 150 'mastername': 'tryserver.chromium.linux', | 150 'mastername': 'tryserver.chromium.linux', |
| 151 'buildername': 'linux_variable', | 151 'buildername': 'linux_variable', |
| 152 'slavename': 'build1-a1', | 152 'slavename': 'build1-a1', |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 164 yield ( | 164 yield ( |
| 165 api.test('compile_specified_targets') + | 165 api.test('compile_specified_targets') + |
| 166 props(compile_targets=['target_name']) | 166 props(compile_targets=['target_name']) |
| 167 ) | 167 ) |
| 168 | 168 |
| 169 yield ( | 169 yield ( |
| 170 api.test('compile_default_targets') + | 170 api.test('compile_default_targets') + |
| 171 props() + | 171 props() + |
| 172 api.override_step_data('test r1.read test spec', | 172 api.override_step_data('test r1.read test spec', |
| 173 api.json.output({ | 173 api.json.output({ |
| 174 'Linux Builder': { | 174 'Linux Builder': { |
| 175 'additional_compile_targets': [ | 175 'additional_compile_targets': [ |
| 176 'base_unittests', | 176 'base_unittests', |
| 177 ], | 177 ], |
| 178 } | 178 } |
| 179 })) | 179 })) |
| 180 ) | 180 ) |
| 181 | 181 |
| 182 yield ( | 182 yield ( |
| 183 api.test('compile_succeeded') + | 183 api.test('compile_succeeded') + |
| 184 props() + | 184 props() + |
| 185 api.override_step_data('test r1.compile', retcode=1) | 185 api.override_step_data('test r1.compile', retcode=1) |
| 186 ) | 186 ) |
| 187 | 187 |
| 188 yield ( | 188 yield ( |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 219 'test_targets': [], | 219 'test_targets': [], |
| 220 }) | 220 }) |
| 221 ) | 221 ) |
| 222 ) | 222 ) |
| 223 | 223 |
| 224 yield ( | 224 yield ( |
| 225 api.test('compile_affected_targets_only') + | 225 api.test('compile_affected_targets_only') + |
| 226 props(use_analyze=True) + | 226 props(use_analyze=True) + |
| 227 api.override_step_data('test r1.read test spec', | 227 api.override_step_data('test r1.read test spec', |
| 228 api.json.output({ | 228 api.json.output({ |
| 229 'Linux Builder': { | 229 'Linux Builder': { |
| 230 'additional_compile_targets': [ | 230 'additional_compile_targets': [ |
| 231 'a', 'a_run', | 231 'a', 'a_run', |
| 232 'b', 'b_run', | 232 'b', 'b_run', |
| 233 ], | 233 ], |
| 234 } | 234 } |
| 235 })) + | 235 })) + |
| 236 api.override_step_data( | 236 api.override_step_data( |
| 237 'test r1.analyze', | 237 'test r1.analyze', |
| 238 api.json.output({ | 238 api.json.output({ |
| 239 'status': 'Found dependency', | 239 'status': 'Found dependency', |
| 240 'compile_targets': ['a', 'a_run'], | 240 'compile_targets': ['a', 'a_run'], |
| 241 'test_targets': ['a', 'a_run'], | 241 'test_targets': ['a', 'a_run'], |
| 242 }) | 242 }) |
| 243 ) | 243 ) |
| 244 ) | 244 ) |
| OLD | NEW |