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

Unified Diff: third_party/WebKit/PRESUBMIT_test.py

Issue 2236993002: Do not call check-webkit-style with empty affected file list as it tries to check all edited files … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « third_party/WebKit/PRESUBMIT.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/PRESUBMIT_test.py
diff --git a/third_party/WebKit/PRESUBMIT_test.py b/third_party/WebKit/PRESUBMIT_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..6a87437b7fc03b522de3bb18fd04ff976466de1b
--- /dev/null
+++ b/third_party/WebKit/PRESUBMIT_test.py
@@ -0,0 +1,69 @@
+# disable camel case warning
+# pylint: disable=C0103
+import PRESUBMIT
+
+import mock
+import subprocess
+import unittest
+
+from PRESUBMIT_test_mocks import MockInputApi, MockOutputApi, MockAffectedFile # pylint: disable=F0401
+
+
+class Capture(object):
+ """
+ Class to capture a call argument that can be tested later on.
+ """
+ def __init__(self):
+ self.value = None
+
+ def __eq__(self, other):
+ self.value = other
+ return True
+
+
+class PresubmitTest(unittest.TestCase):
+
+ @mock.patch('subprocess.Popen')
+ def testCheckChangeOnUploadWithWebKitAndChromiumFiles(self, _):
+ """
+ This verifies that CheckChangeOnUpload will only call check-webkit-style
+ on WebKit files.
+ """
+ diff_file_webkit_h = ['some diff']
+ diff_file_chromium_h = ['another diff']
+ mock_input_api = MockInputApi()
+ mock_input_api.files = [MockAffectedFile('FileWebkit.h',
+ diff_file_webkit_h),
+ MockAffectedFile('file_chromium.h',
+ diff_file_chromium_h)]
+ # Access to a protected member _CheckStyle
+ # pylint: disable=W0212
+ PRESUBMIT._CheckStyle(mock_input_api, MockOutputApi())
+ capture = Capture()
+ # pylint: disable=E1101
+ subprocess.Popen.assert_called_with(capture, stderr=-1)
+ self.assertEqual(4, len(capture.value))
+ self.assertEqual('../../FileWebkit.h', capture.value[3])
+
+ @mock.patch('subprocess.Popen')
+ def testCheckChangeOnUploadWithEmptyAffectedFileList(self, _):
+ """
+ This verifies that CheckChangeOnUpload will skip calling
+ check-webkit-style if the affected file list is empty.
+ """
+ diff_file_chromium1_h = ['some diff']
+ diff_file_chromium2_h = ['another diff']
+ mock_input_api = MockInputApi()
+ mock_input_api.files = [MockAffectedFile('first_file_chromium.h',
+ diff_file_chromium1_h),
+ MockAffectedFile('second_file_chromium.h',
+ diff_file_chromium2_h)]
+ # Access to a protected member _CheckStyle
+ # pylint: disable=W0212
+ PRESUBMIT._CheckStyle(mock_input_api, MockOutputApi())
+ # pylint: disable=E1101
+ subprocess.Popen.assert_not_called()
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « third_party/WebKit/PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698