| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 contextlib | 5 import contextlib |
| 6 import copy | 6 import copy |
| 7 import itertools | 7 import itertools |
| 8 import json | 8 import json |
| 9 | 9 |
| 10 from recipe_engine.types import freeze | 10 from recipe_engine.types import freeze |
| 11 from recipe_engine import recipe_api | 11 from recipe_engine import recipe_api |
| 12 from recipe_engine import util as recipe_util | |
| 13 | 12 |
| 14 from . import bot_config_and_test_db as bdb_module | 13 from . import bot_config_and_test_db as bdb_module |
| 15 from . import builders | 14 from . import builders |
| 16 from . import steps | 15 from . import steps |
| 17 from . import trybots | 16 from . import trybots |
| 18 | 17 |
| 19 | 18 |
| 20 # Paths which affect recipe config and behavior in a way that survives | 19 # Paths which affect recipe config and behavior in a way that survives |
| 21 # deapplying user's patch. | 20 # deapplying user's patch. |
| 22 RECIPE_CONFIG_PATHS = [ | 21 RECIPE_CONFIG_PATHS = [ |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 patch_root = self.m.gclient.calculate_patch_root( | 655 patch_root = self.m.gclient.calculate_patch_root( |
| 657 self.m.properties.get('patch_project')) | 656 self.m.properties.get('patch_project')) |
| 658 cwd = self._working_dir.join(patch_root) if self._working_dir else None | 657 cwd = self._working_dir.join(patch_root) if self._working_dir else None |
| 659 files = self.m.tryserver.get_files_affected_by_patch(patch_root, cwd=cwd) | 658 files = self.m.tryserver.get_files_affected_by_patch(patch_root, cwd=cwd) |
| 660 for i, path in enumerate(files): | 659 for i, path in enumerate(files): |
| 661 path = str(path) | 660 path = str(path) |
| 662 assert path.startswith(relative_to) | 661 assert path.startswith(relative_to) |
| 663 files[i] = path[len(relative_to):] | 662 files[i] = path[len(relative_to):] |
| 664 return files | 663 return files |
| 665 | 664 |
| 666 def analyze(self, affected_files, test_targets, additional_compile_targets, | |
| 667 config_file_name, mb_mastername=None, mb_buildername=None, | |
| 668 additional_names=None): | |
| 669 """Runs "analyze" step to determine targets affected by the patch. | |
| 670 | |
| 671 Returns a tuple of: | |
| 672 - list of targets that are needed to run tests (see filter recipe module) | |
| 673 - list of targets that need to be compiled (see filter recipe module)""" | |
| 674 | |
| 675 if additional_names is None: | |
| 676 additional_names = ['chromium'] | |
| 677 | |
| 678 use_mb = (self.m.chromium.c.project_generator.tool == 'mb') | |
| 679 build_output_dir = '//out/%s' % self.m.chromium.c.build_config_fs | |
| 680 self.m.filter.does_patch_require_compile( | |
| 681 affected_files, | |
| 682 test_targets=test_targets, | |
| 683 additional_compile_targets=additional_compile_targets, | |
| 684 additional_names=additional_names, | |
| 685 config_file_name=config_file_name, | |
| 686 use_mb=use_mb, | |
| 687 mb_mastername=mb_mastername, | |
| 688 mb_buildername=mb_buildername, | |
| 689 build_output_dir=build_output_dir, | |
| 690 cros_board=self.m.chromium.c.TARGET_CROS_BOARD) | |
| 691 | |
| 692 compile_targets = self.m.filter.compile_targets[:] | |
| 693 | |
| 694 # Emit more detailed output useful for debugging. | |
| 695 analyze_details = { | |
| 696 'test_targets': test_targets, | |
| 697 'additional_compile_targets': additional_compile_targets, | |
| 698 'self.m.filter.compile_targets': self.m.filter.compile_targets, | |
| 699 'self.m.filter.test_targets': self.m.filter.test_targets, | |
| 700 'compile_targets': compile_targets, | |
| 701 } | |
| 702 with contextlib.closing(recipe_util.StringListIO()) as listio: | |
| 703 json.dump(analyze_details, listio, indent=2, sort_keys=True) | |
| 704 step_result = self.m.step.active_result | |
| 705 step_result.presentation.logs['analyze_details'] = listio.lines | |
| 706 | |
| 707 return self.m.filter.test_targets, compile_targets | |
| 708 | |
| 709 # TODO(phajdan.jr): fix callers and remove chromium_tests.configure_swarming. | 665 # TODO(phajdan.jr): fix callers and remove chromium_tests.configure_swarming. |
| 710 def configure_swarming(self, project_name, precommit, mastername=None): | 666 def configure_swarming(self, project_name, precommit, mastername=None): |
| 711 return self.m.chromium_swarming.configure_swarming( # pragma: no cover | 667 return self.m.chromium_swarming.configure_swarming( # pragma: no cover |
| 712 project_name, precommit, mastername) | 668 project_name, precommit, mastername) |
| 713 | 669 |
| 714 def _build_gs_archive_url(self, mastername, master_config, buildername): | 670 def _build_gs_archive_url(self, mastername, master_config, buildername): |
| 715 """Returns the archive URL to pass to self.m.archive.zip_and_upload_build. | 671 """Returns the archive URL to pass to self.m.archive.zip_and_upload_build. |
| 716 | 672 |
| 717 Most builders on most masters use a standard format for the build archive | 673 Most builders on most masters use a standard format for the build archive |
| 718 URL, but some builders on some masters may specify custom places to upload | 674 URL, but some builders on some masters may specify custom places to upload |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 def get_compile_targets_for_scripts(self): | 734 def get_compile_targets_for_scripts(self): |
| 779 return self.m.python( | 735 return self.m.python( |
| 780 name='get compile targets for scripts', | 736 name='get compile targets for scripts', |
| 781 script=self.m.path['checkout'].join( | 737 script=self.m.path['checkout'].join( |
| 782 'testing', 'scripts', 'get_compile_targets.py'), | 738 'testing', 'scripts', 'get_compile_targets.py'), |
| 783 args=[ | 739 args=[ |
| 784 '--output', self.m.json.output(), | 740 '--output', self.m.json.output(), |
| 785 '--', | 741 '--', |
| 786 ] + self.get_common_args_for_scripts(), | 742 ] + self.get_common_args_for_scripts(), |
| 787 step_test_data=lambda: self.m.json.test_api.output({})) | 743 step_test_data=lambda: self.m.json.test_api.output({})) |
| OLD | NEW |