Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 import json | |
| 6 | |
| 7 from recipe_engine.config import List | |
| 8 from recipe_engine.recipe_api import Property | |
| 9 | |
| 10 | |
| 11 DEPS = [ | |
| 12 'chromium', | |
| 13 'chromium_tests', | |
| 14 'findit', | |
| 15 'gclient', | |
| 16 'json', | |
| 17 'path', | |
| 18 'properties', | |
| 19 'python', | |
| 20 'step', | |
| 21 ] | |
| 22 | |
| 23 | |
| 24 PROPERTIES = { | |
| 25 'target_mastername': Property( | |
| 26 kind=str, help='The target master to match compile config to.'), | |
| 27 'target_buildername': Property( | |
| 28 kind=str, help='The target builder to match compile config to.'), | |
| 29 'target_solution': Property( | |
| 30 kind=str, help='The gclient solution, eg: src for chromium.'), | |
| 31 'target_solution_revisions': Property( | |
| 32 kind=List(basestring), | |
| 33 help='The revisions to be tested for compile failure, ' | |
| 34 'ordered from older revisions to newer revisions.'), | |
| 35 'compile_targets': Property( | |
| 36 kind=List(basestring), default=None, param_name='compile_targets', | |
|
iannucci
2015/11/18 03:57:54
yay! real types!
Please note that in order for th
stgao
2015/11/19 22:06:34
Yes, it will be a list of strings in the build req
| |
| 37 help='The failed compile targets, eg: browser_tests, a/b.o'), | |
|
Dirk Pranke
2015/11/17 22:38:51
nit: it's not clear what "a/b.o" is here; is that
stgao
2015/11/19 22:06:34
Yes, it's supposed to be an arbitrary object file.
| |
| 38 } | |
| 39 | |
| 40 | |
| 41 def RunSteps(api, target_mastername, target_buildername, | |
| 42 target_solution, target_solution_revisions, | |
| 43 compile_targets): | |
| 44 api.chromium_tests.configure_build( | |
| 45 target_mastername, target_buildername, override_bot_type='builder_tester') | |
| 46 | |
| 47 results = [] | |
| 48 try: | |
| 49 for current_revision in target_solution_revisions: | |
| 50 with api.step.nest('test %s' % str(current_revision)): | |
| 51 # Configure the revision to recompile. | |
| 52 cfg = api.gclient.c | |
| 53 if not cfg.revisions: | |
| 54 cfg.revisions = {} | |
| 55 cfg.revisions.update({ | |
| 56 target_solution: current_revision, | |
| 57 }) | |
|
iannucci
2015/11/18 03:57:54
This is mutating `api.gclient.c`.
I think a more
stgao
2015/11/19 22:06:34
Yes, it works!
| |
| 58 | |
| 59 bot_update_step, master_dict, test_spec = \ | |
| 60 api.chromium_tests.prepare_checkout( | |
| 61 target_mastername, | |
| 62 target_buildername) | |
| 63 | |
| 64 # If no compile target is provided, use analyze to filter out the | |
| 65 # impacted compile targets by the current revision. | |
| 66 compile_targets = sorted(set(compile_targets or [])) | |
| 67 if not compile_targets: | |
| 68 affected_files = \ | |
| 69 api.findit.get_files_affected_by_revision(current_revision) | |
| 70 | |
| 71 all_compile_targets, _ = \ | |
| 72 api.chromium_tests.get_compile_targets_and_tests( | |
| 73 target_mastername, | |
| 74 target_buildername, | |
| 75 master_dict, | |
| 76 test_spec, | |
| 77 override_bot_type='builder_tester', | |
| 78 override_tests=[]) | |
| 79 | |
| 80 requires_compile, matching_exes, compile_targets = \ | |
|
Dirk Pranke
2015/11/17 22:38:51
You should update this logic to the latest version
stgao
2015/11/19 22:06:34
Done.
Also refactored chromium_tests.get_compile_
| |
| 81 api.chromium_tests.analyze( | |
| 82 affected_files, | |
| 83 all_compile_targets, | |
| 84 all_compile_targets, | |
| 85 'trybot_analyze_config.json') | |
| 86 | |
| 87 | |
| 88 if not requires_compile: | |
| 89 compile_targets = [] | |
| 90 else: | |
| 91 # Note that compile_targets doesn't necessarily include | |
| 92 # matching_exes, and for correctness we need to add them. Otherwise | |
| 93 # it's possible we'd only build foo_unittests but not | |
| 94 # foo_unittests_run. | |
| 95 compile_targets = sorted(set(compile_targets + matching_exes)) | |
| 96 | |
| 97 if not compile_targets: | |
| 98 # No compile target is impacted by the current revision. | |
| 99 results.append([current_revision, 'skip']) | |
| 100 continue | |
|
iannucci
2015/11/18 03:57:54
I would maybe pull this loop body into a function
stgao
2015/11/19 22:06:34
Done.
| |
| 101 | |
| 102 try: | |
| 103 api.chromium_tests.compile_specific_targets( | |
| 104 target_mastername, | |
| 105 target_buildername, | |
| 106 bot_update_step, | |
| 107 master_dict, | |
| 108 compile_targets, | |
| 109 [], # Not run any test. | |
| 110 override_bot_type='builder_tester') | |
| 111 results.append([current_revision, 'pass']) | |
| 112 except api.step.InfraFailure: | |
| 113 results.append([current_revision, 'unknown']) | |
| 114 raise | |
| 115 except api.step.StepFailure: | |
| 116 # TODO: if compile targets are specified in the build request, compile | |
| 117 # may fail because those targets are added in a later revision. | |
| 118 results.append([current_revision, 'fail']) | |
| 119 break # Found the culprit, no need to check later revisions. | |
| 120 finally: | |
| 121 # Report the result. | |
| 122 step_result = api.python.inline( | |
| 123 'report', 'import sys; sys.exit(0)', add_python_log=False) | |
| 124 step_result.presentation.logs.setdefault('result', []).append( | |
| 125 json.dumps(results, indent=2)) | |
|
iannucci
2015/11/18 03:57:54
I would consider summarizing the culprit (if we fo
stgao
2015/11/19 22:06:34
Good idea.
Done.
| |
| 126 | |
| 127 return results | |
| 128 | |
| 129 | |
| 130 def GenTests(api): | |
| 131 def props(compile_targets=None): | |
| 132 properties = { | |
| 133 'mastername': 'tryserver.chromium.linux', | |
| 134 'buildername': 'linux_variable', | |
| 135 'slavename': 'build1-a1', | |
| 136 'buildnumber': '1', | |
| 137 'target_mastername': 'chromium.linux', | |
| 138 'target_buildername': 'Linux Builder', | |
| 139 'target_solution': 'src', | |
| 140 'target_solution_revisions': ['r1'], | |
| 141 } | |
| 142 if compile_targets: | |
| 143 properties['compile_targets'] = compile_targets | |
| 144 return api.properties(**properties) | |
| 145 | |
| 146 yield ( | |
| 147 api.test('compile_skipped') + | |
| 148 props() + | |
| 149 api.override_step_data( | |
| 150 'test r1.analyze', | |
| 151 api.json.output({ | |
| 152 'build_targets': [], | |
| 153 'status': 'No dependencies', | |
| 154 'targets': [], | |
| 155 }) | |
| 156 ) | |
| 157 ) | |
| 158 | |
| 159 yield ( | |
| 160 api.test('compile_targets_returned_by_analyze') + | |
| 161 props() + | |
| 162 api.override_step_data( | |
| 163 'test r1.analyze', | |
| 164 api.json.output({ | |
| 165 'build_targets': ['test_target'], | |
| 166 'status': 'Found dependency', | |
| 167 'targets': ['test_target_run'], | |
| 168 }) | |
| 169 ) | |
| 170 ) | |
| 171 | |
| 172 yield ( | |
| 173 api.test('compile_specified_targets') + | |
| 174 props(compile_targets=['obj/a/b/c.o']) | |
| 175 ) | |
| 176 | |
| 177 yield ( | |
| 178 api.test('compile_failed') + | |
| 179 props(compile_targets=['obj/a/b/c.o']) + | |
| 180 api.override_step_data('test r1.compile', retcode=1) | |
| 181 ) | |
| 182 | |
| 183 yield ( | |
| 184 api.test('compile_failed_infra') + | |
| 185 props(compile_targets=['obj/a/b/c.o']) + | |
| 186 api.override_step_data( | |
| 187 'test r1.compile', | |
| 188 api.json.output({ | |
| 189 'notice': [ | |
| 190 { | |
| 191 'infra_status': { | |
| 192 'ping_status_code': 408, | |
| 193 }, | |
| 194 }, | |
| 195 ], | |
| 196 }), | |
| 197 retcode=1) | |
| 198 ) | |
| OLD | NEW |