Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: scripts/slave/recipe_modules/chromium_tests/api.py

Issue 2327543002: chromium_tests: add an option to disable deapplying patch on some trybots (Closed)
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/chromium_tests/trybots.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 collections 5 import collections
6 import contextlib 6 import contextlib
7 import copy 7 import copy
8 import itertools 8 import itertools
9 import json 9 import json
10 10
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 # TODO(tandrii): remove this per http://crbug.com/635641. 680 # TODO(tandrii): remove this per http://crbug.com/635641.
681 if self.m.platform.is_linux: 681 if self.m.platform.is_linux:
682 kwargs['env'] = {'GCLIENT_KILL_GIT_FETCH_AFTER': '1200'} # 20 minutes. 682 kwargs['env'] = {'GCLIENT_KILL_GIT_FETCH_AFTER': '1200'} # 20 minutes.
683 683
684 self.m.bot_update.ensure_checkout( 684 self.m.bot_update.ensure_checkout(
685 patch=False, update_presentation=False, **kwargs) 685 patch=False, update_presentation=False, **kwargs)
686 self.m.chromium.runhooks(name='runhooks (without patch)') 686 self.m.chromium.runhooks(name='runhooks (without patch)')
687 687
688 def run_tests_on_tryserver(self, bot_config, api, tests, bot_update_step, 688 def run_tests_on_tryserver(self, bot_config, api, tests, bot_update_step,
689 affected_files, mb_mastername=None, 689 affected_files, mb_mastername=None,
690 mb_buildername=None): 690 mb_buildername=None, disable_deapply_patch=False):
691 def deapply_patch_fn(failing_tests): 691 def deapply_patch_fn(failing_tests):
692 self.deapply_patch(bot_update_step) 692 self.deapply_patch(bot_update_step)
693 compile_targets = list(itertools.chain( 693 compile_targets = list(itertools.chain(
694 *[t.compile_targets(api) for t in failing_tests])) 694 *[t.compile_targets(api) for t in failing_tests]))
695 if compile_targets: 695 if compile_targets:
696 # Remove duplicate targets. 696 # Remove duplicate targets.
697 compile_targets = sorted(set(compile_targets)) 697 compile_targets = sorted(set(compile_targets))
698 failing_swarming_tests = [ 698 failing_swarming_tests = [
699 t.isolate_target(api) for t in failing_tests if t.uses_swarming] 699 t.isolate_target(api) for t in failing_tests if t.uses_swarming]
700 if failing_swarming_tests: 700 if failing_swarming_tests:
701 self.m.isolate.clean_isolated_files(self.m.chromium.output_dir) 701 self.m.isolate.clean_isolated_files(self.m.chromium.output_dir)
702 self.run_mb_and_compile(compile_targets, failing_swarming_tests, 702 self.run_mb_and_compile(compile_targets, failing_swarming_tests,
703 ' (without patch)', 703 ' (without patch)',
704 mb_mastername=mb_mastername, 704 mb_mastername=mb_mastername,
705 mb_buildername=mb_buildername) 705 mb_buildername=mb_buildername)
706 if failing_swarming_tests: 706 if failing_swarming_tests:
707 self.m.isolate.isolate_tests(self.m.chromium.output_dir, 707 self.m.isolate.isolate_tests(self.m.chromium.output_dir,
708 verbose=True) 708 verbose=True)
709 709
710 deapply_patch = True 710 deapply_patch = True
711 deapply_patch_reason = 'unknown reason' 711 deapply_patch_reason = 'unknown reason'
712 for path in RECIPE_CONFIG_PATHS: 712 for path in RECIPE_CONFIG_PATHS:
713 if any([f.startswith(path) for f in affected_files]): 713 if any([f.startswith(path) for f in affected_files]):
714 deapply_patch = False 714 deapply_patch = False
715 deapply_patch_reason = 'build config changes detected' 715 deapply_patch_reason = 'build config changes detected'
716 break 716 break
717 if disable_deapply_patch:
718 deapply_patch = False
719 deapply_patch_reason = 'disabled in recipes'
717 720
718 with self.wrap_chromium_tests(bot_config, tests): 721 with self.wrap_chromium_tests(bot_config, tests):
719 if deapply_patch: 722 if deapply_patch:
720 self.m.test_utils.determine_new_failures(api, tests, deapply_patch_fn) 723 self.m.test_utils.determine_new_failures(api, tests, deapply_patch_fn)
721 else: 724 else:
722 failing_tests = self.m.test_utils.run_tests_with_patch(api, tests) 725 failing_tests = self.m.test_utils.run_tests_with_patch(api, tests)
723 if failing_tests: 726 if failing_tests:
724 self.m.python.failing_step( 727 self.m.python.failing_step(
725 'test results', 728 'test results',
726 'TESTS FAILED; retries without patch disabled (%s)' 729 'TESTS FAILED; retries without patch disabled (%s)'
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 test_runner() 856 test_runner()
854 857
855 @staticmethod 858 @staticmethod
856 # TODO(phajdan.jr): try to get rid of api parameter. 859 # TODO(phajdan.jr): try to get rid of api parameter.
857 # We currently have to use it because clients of this dereference 860 # We currently have to use it because clients of this dereference
858 # chromium_tests, and currently recipe engine does not set up 861 # chromium_tests, and currently recipe engine does not set up
859 # self-reference self.m.chromium_tests in chromium_tests. 862 # self-reference self.m.chromium_tests in chromium_tests.
860 def trybot_steps(api): 863 def trybot_steps(api):
861 with api.tryserver.set_failure_hash(): 864 with api.tryserver.set_failure_hash():
862 try: 865 try:
863 bot_config_object, bot_update_step, affected_files, tests = \ 866 (bot_config_object, bot_update_step, affected_files, tests,
864 ChromiumTestsApi._trybot_steps_internal(api) 867 disable_deapply_patch) = ChromiumTestsApi._trybot_steps_internal(api)
865 finally: 868 finally:
866 api.python.succeeding_step('mark: before_tests', '') 869 api.python.succeeding_step('mark: before_tests', '')
867 870
868 if tests: 871 if tests:
869 api.chromium_tests.run_tests_on_tryserver( 872 api.chromium_tests.run_tests_on_tryserver(
870 bot_config_object, api, tests, bot_update_step, affected_files) 873 bot_config_object, api, tests, bot_update_step, affected_files,
874 disable_deapply_patch=disable_deapply_patch)
871 875
872 @staticmethod 876 @staticmethod
873 # TODO(phajdan.jr): try to get rid of api parameter. 877 # TODO(phajdan.jr): try to get rid of api parameter.
874 # We currently have to use it because clients of this dereference 878 # We currently have to use it because clients of this dereference
875 # chromium_tests, and currently recipe engine does not set up 879 # chromium_tests, and currently recipe engine does not set up
876 # self-reference self.m.chromium_tests in chromium_tests. 880 # self-reference self.m.chromium_tests in chromium_tests.
877 def _trybot_steps_internal(api): 881 def _trybot_steps_internal(api):
878 mastername = api.properties.get('mastername') 882 mastername = api.properties.get('mastername')
879 buildername = api.properties.get('buildername') 883 buildername = api.properties.get('buildername')
880 bot_config = api.chromium_tests.trybots.get(mastername, {}).get( 884 bot_config = api.chromium_tests.trybots.get(mastername, {}).get(
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 else: 986 else:
983 # Even though the patch doesn't require a compile on this platform, 987 # Even though the patch doesn't require a compile on this platform,
984 # we'd still like to run tests not depending on 988 # we'd still like to run tests not depending on
985 # compiled targets (that's obviously not covered by the 989 # compiled targets (that's obviously not covered by the
986 # 'analyze' step) if any source files change. 990 # 'analyze' step) if any source files change.
987 if any(ChromiumTestsApi._is_source_file(api, f) for f in affected_files): 991 if any(ChromiumTestsApi._is_source_file(api, f) for f in affected_files):
988 tests = [t for t in tests if not t.compile_targets(api)] 992 tests = [t for t in tests if not t.compile_targets(api)]
989 else: 993 else:
990 tests = [] 994 tests = []
991 995
992 return bot_config_object, bot_update_step, affected_files, tests 996 disable_deapply_patch = not bot_config.get('deapply_patch', True)
997 return (bot_config_object, bot_update_step, affected_files, tests,
998 disable_deapply_patch)
993 999
994 @staticmethod 1000 @staticmethod
995 def _all_compile_targets(api, tests): 1001 def _all_compile_targets(api, tests):
996 """Returns the compile_targets for all the Tests in |tests|.""" 1002 """Returns the compile_targets for all the Tests in |tests|."""
997 return sorted(set(x 1003 return sorted(set(x
998 for test in tests 1004 for test in tests
999 for x in test.compile_targets(api))) 1005 for x in test.compile_targets(api)))
1000 1006
1001 @staticmethod 1007 @staticmethod
1002 def _is_source_file(api, filepath): 1008 def _is_source_file(api, filepath):
1003 """Returns true iff the file is a source file.""" 1009 """Returns true iff the file is a source file."""
1004 _, ext = api.path.splitext(filepath) 1010 _, ext = api.path.splitext(filepath)
1005 return ext in ['.c', '.cc', '.cpp', '.h', '.java', '.mm'] 1011 return ext in ['.c', '.cc', '.cpp', '.h', '.java', '.mm']
1006 1012
1007 @staticmethod 1013 @staticmethod
1008 def _tests_in_compile_targets(api, compile_targets, tests): 1014 def _tests_in_compile_targets(api, compile_targets, tests):
1009 """Returns the tests in |tests| that have at least one of their compile 1015 """Returns the tests in |tests| that have at least one of their compile
1010 targets in |compile_targets|.""" 1016 targets in |compile_targets|."""
1011 result = [] 1017 result = []
1012 for test in tests: 1018 for test in tests:
1013 test_compile_targets = test.compile_targets(api) 1019 test_compile_targets = test.compile_targets(api)
1014 # Always return tests that don't require compile. Otherwise we'd never 1020 # Always return tests that don't require compile. Otherwise we'd never
1015 # run them. 1021 # run them.
1016 if ((set(compile_targets) & set(test_compile_targets)) or 1022 if ((set(compile_targets) & set(test_compile_targets)) or
1017 not test_compile_targets): 1023 not test_compile_targets):
1018 result.append(test) 1024 result.append(test)
1019 return result 1025 return result
OLDNEW
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/chromium_tests/trybots.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698