| 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 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 # sub-range1: r7 and [r8, r9, r10] | 161 # sub-range1: r7 and [r8, r9, r10] |
| 162 # sub-range2: r4 and [r5, r6] | 162 # sub-range2: r4 and [r5, r6] |
| 163 # sub-range3: None and [r1, r2, r3] | 163 # sub-range3: None and [r1, r2, r3] |
| 164 # Sub-ranges with newer revisions are tested first (sub-range1 -> sub-range2 | 164 # Sub-ranges with newer revisions are tested first (sub-range1 -> sub-range2 |
| 165 # -> sub-range3), because it is more likely that a newer revision is the | 165 # -> sub-range3), because it is more likely that a newer revision is the |
| 166 # beginning of the compile breakage. | 166 # beginning of the compile breakage. |
| 167 suspected_revision_index = [ | 167 suspected_revision_index = [ |
| 168 all_revisions.index(r) | 168 all_revisions.index(r) |
| 169 for r in set(suspected_revisions) if r in all_revisions] | 169 for r in set(suspected_revisions) if r in all_revisions] |
| 170 if suspected_revision_index: | 170 if suspected_revision_index: |
| 171 # For consecutive suspected revisions, make them all in the same sub-range |
| 172 # by removing the newer revisions, but keep the oldest one. |
| 173 suspected_revision_index = [i for i in suspected_revision_index |
| 174 if i - 1 not in suspected_revision_index] |
| 175 |
| 171 sub_ranges = [] | 176 sub_ranges = [] |
| 172 remaining_revisions = all_revisions[:] | 177 remaining_revisions = all_revisions[:] |
| 173 for index in sorted(suspected_revision_index, reverse=True): | 178 for index in sorted(suspected_revision_index, reverse=True): |
| 174 if index > 0: | 179 if index > 0: |
| 175 sub_ranges.append(remaining_revisions[index - 1:]) | 180 sub_ranges.append(remaining_revisions[index - 1:]) |
| 176 remaining_revisions = remaining_revisions[:index - 1] | 181 remaining_revisions = remaining_revisions[:index - 1] |
| 177 # None is a placeholder for the last known good revision. | 182 # None is a placeholder for the last known good revision. |
| 178 sub_ranges.append([None] + remaining_revisions) | 183 sub_ranges.append([None] + remaining_revisions) |
| 179 else: | 184 else: |
| 180 # Treat the entire regression range as a single sub-range. | 185 # Treat the entire regression range as a single sub-range. |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 })) + | 450 })) + |
| 446 api.override_step_data('test r4.check_targets', | 451 api.override_step_data('test r4.check_targets', |
| 447 api.json.output({ | 452 api.json.output({ |
| 448 'found': ['target_name'], | 453 'found': ['target_name'], |
| 449 'not_found': [], | 454 'not_found': [], |
| 450 })) + | 455 })) + |
| 451 api.override_step_data('test r4.compile', retcode=1) | 456 api.override_step_data('test r4.compile', retcode=1) |
| 452 ) | 457 ) |
| 453 | 458 |
| 454 # Entire regression range: (r1, r6] | 459 # Entire regression range: (r1, r6] |
| 455 # Suspected_revisions: [r4] | 460 # Suspected_revisions: [r4, r5] |
| 456 # Expected smaller ranges: [r3, [r4, r5, r6]], [None, [r2]] | 461 # Expected smaller ranges: [r3, [r4, r5, r6]], [None, [r2]] |
| 457 # Actual culprit: r3 | 462 # Actual culprit: r3 |
| 458 # Should only run compile on r3, and then r2. | 463 # Should only run compile on r3, and then r2. |
| 459 yield ( | 464 yield ( |
| 460 api.test('find_culprit_at_first_revision_of_a_sub_range') + | 465 api.test('find_culprit_at_first_revision_of_a_sub_range') + |
| 461 props(compile_targets=['target_name'], | 466 props(compile_targets=['target_name'], |
| 462 good_revision='r1', | 467 good_revision='r1', |
| 463 bad_revision='r6', | 468 bad_revision='r6', |
| 464 suspected_revisions=['r4']) + | 469 suspected_revisions=['r4']) + |
| 465 api.override_step_data( | 470 api.override_step_data( |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 'git commits in range', | 535 'git commits in range', |
| 531 api.raw_io.stream_output( | 536 api.raw_io.stream_output( |
| 532 '\n'.join('r%d' % i for i in reversed(range(2, 6))))) + | 537 '\n'.join('r%d' % i for i in reversed(range(2, 6))))) + |
| 533 api.override_step_data('test r2.check_targets', | 538 api.override_step_data('test r2.check_targets', |
| 534 api.json.output({ | 539 api.json.output({ |
| 535 'found': ['target_name'], | 540 'found': ['target_name'], |
| 536 'not_found': [], | 541 'not_found': [], |
| 537 })) + | 542 })) + |
| 538 api.override_step_data('test r2.compile', retcode=1) | 543 api.override_step_data('test r2.compile', retcode=1) |
| 539 ) | 544 ) |
| OLD | NEW |