diff --git a/presubmit_support.py b/presubmit_support.py index 5b89a335d..c1edc9493 100755 --- a/presubmit_support.py +++ b/presubmit_support.py @@ -1513,17 +1513,14 @@ def load_files(options, args): return change_class, files -class NonexistantCannedCheckFilter(Exception): - pass - - @contextlib.contextmanager def canned_check_filter(method_names): filtered = {} try: for method_name in method_names: if not hasattr(presubmit_canned_checks, method_name): - raise NonexistantCannedCheckFilter(method_name) + logging.warn('Skipping unknown "canned" check %s' % method_name) + continue filtered[method_name] = getattr(presubmit_canned_checks, method_name) setattr(presubmit_canned_checks, method_name, lambda *_a, **_kw: []) yield @@ -1692,10 +1689,6 @@ def main(argv=None): gerrit_obj, options.dry_run) return not results.should_continue() - except NonexistantCannedCheckFilter, e: - print >> sys.stderr, ( - 'Attempted to skip nonexistent canned presubmit check: %s' % e.message) - return 2 except PresubmitFailure, e: print >> sys.stderr, e print >> sys.stderr, 'Maybe your depot_tools is out of date?' diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index 5cd68a9d1..63a1f0b5e 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -175,7 +175,7 @@ class PresubmitUnittest(PresubmitTestsBase): 'AffectedFile', 'Change', 'DoPostUploadExecuter', 'DoPresubmitChecks', 'GetPostUploadExecuter', 'GitAffectedFile', 'CallCommand', 'CommandData', 'GitChange', 'InputApi', 'ListRelevantPresubmitFiles', 'main', - 'NonexistantCannedCheckFilter', 'OutputApi', 'ParseFiles', + 'OutputApi', 'ParseFiles', 'PresubmitFailure', 'PresubmitExecuter', 'PresubmitOutput', 'ScanSubDirs', 'ast', 'auth', 'cPickle', 'cpplint', 'cStringIO', 'contextlib', 'canned_check_filter', 'fix_encoding', 'fnmatch', 'gclient_utils', @@ -198,15 +198,6 @@ class PresubmitUnittest(PresubmitTestsBase): self.assertEqual(canned.CheckOwners(None, None), []) self.assertEqual(canned.CheckOwners, orig) - def testCannedCheckFilterFail(self): - canned = presubmit.presubmit_canned_checks - orig = canned.CheckOwners - def failAttempt(): - with presubmit.canned_check_filter(['CheckOwners', 'Spazfleem']): - pass - self.assertRaises(presubmit.NonexistantCannedCheckFilter, failAttempt) - self.assertEqual(canned.CheckOwners, orig) - def testListRelevantPresubmitFiles(self): files = [ 'blat.cc',