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

Unified Diff: tests/presubmit_unittest.py

Issue 12481002: Add skip_canned option to presubmit_support. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Restore canned checks and add tests! Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« presubmit_support.py ('K') | « presubmit_support.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/presubmit_unittest.py
diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py
index a85d3625a0ca093bc2e50fdf93823f21b0584b96..13145493e08c5da1f3f2f0a90b7b94ee3466be8b 100755
--- a/tests/presubmit_unittest.py
+++ b/tests/presubmit_unittest.py
@@ -159,11 +159,11 @@ class PresubmitUnittest(PresubmitTestsBase):
'AffectedFile', 'Change', 'DoGetTrySlaves', 'DoPresubmitChecks',
'GetTrySlavesExecuter', 'GitAffectedFile',
'GitChange', 'InputApi', 'ListRelevantPresubmitFiles', 'Main',
- 'OutputApi', 'ParseFiles', 'PresubmitFailure',
- 'PresubmitExecuter', 'PresubmitOutput', 'ScanSubDirs',
- 'SvnAffectedFile', 'SvnChange', 'cPickle', 'cStringIO',
- 'fix_encoding', 'fnmatch', 'gclient_utils', 'glob', 'inspect', 'json',
- 'load_files',
+ 'NonexistantCannedCheckFilter', 'OutputApi', 'ParseFiles',
+ 'PresubmitFailure', 'PresubmitExecuter', 'PresubmitOutput', 'ScanSubDirs',
+ 'SvnAffectedFile', 'SvnChange', 'cPickle', 'cStringIO', 'contextlib',
+ 'canned_check_filter', 'fix_encoding', 'fnmatch', 'gclient_utils', 'glob',
+ 'inspect', 'json', 'load_files',
'logging', 'marshal', 'normpath', 'optparse', 'os', 'owners', 'pickle',
'presubmit_canned_checks', 'random', 're', 'rietveld', 'scm',
'subprocess',
@@ -173,6 +173,23 @@ class PresubmitUnittest(PresubmitTestsBase):
# If this test fails, you should add the relevant test.
self.compareMembers(presubmit, members)
+ def testCannedCheckFilter(self):
+ canned = presubmit.presubmit_canned_checks
+ orig = canned.CheckOwners
+ with presubmit.canned_check_filter(['CheckOwners']):
+ self.assertNotEqual(canned.CheckOwners, orig)
+ 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):
join = presubmit.os.path.join
files = [
« presubmit_support.py ('K') | « presubmit_support.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698