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

Unified Diff: scripts/slave/unittests/patch_path_filter_test.py

Issue 27575002: Patch path filtering script. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Now using patch.py and its test data Created 7 years, 1 month 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
Index: scripts/slave/unittests/patch_path_filter_test.py
diff --git a/scripts/slave/unittests/patch_path_filter_test.py b/scripts/slave/unittests/patch_path_filter_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..4b0eaecb99e995f570198b77dbce62023e26ba2d
--- /dev/null
+++ b/scripts/slave/unittests/patch_path_filter_test.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import re
+import unittest
+
+import test_env # pylint: disable=W0403,W0611
+
+import slave.patch_path_filter as patch_path_filter
+
+from depot_tools.test_support.patches_data import GIT, RAW
+
+class PatchPathFilterTest(unittest.TestCase):
+
+ def testGitEmpty(self):
+ patchset = patch_path_filter.parse_git_patch_set('')
+ self.assertEqual(0, len(patchset.filenames))
+
+ def testSvnEmpty(self):
+ patchset = patch_path_filter.parse_svn_patch_set('')
+ self.assertEqual(0, len(patchset.filenames))
+
+ def testGitPatch(self):
+ patchset = patch_path_filter.parse_git_patch_set(GIT.PATCH)
+ self._verifyPatch(patchset)
+
+ def testSvnPatch(self):
+ patchset = patch_path_filter.parse_svn_patch_set(RAW.PATCH)
+ self._verifyPatch(patchset)
+
+ def testGitPatchStripped(self):
+ data = re.sub('[a|b]/chrome/file.cc', 'chrome/file.cc', GIT.PATCH)
+ patchset = patch_path_filter.parse_git_patch_set(data)
+ self._verifyPatch(patchset)
+
+ def testGitPatchTwoFiles(self):
+ patchset = patch_path_filter.parse_git_patch_set(GIT.PATCH + GIT.NEW)
+ self.assertEqual(2, len(patchset.filenames))
+ self.assertEqual('chrome/file.cc', patchset.filenames[0])
+ self.assertEqual('foo', patchset.filenames[1])
+
+ def testSvnPatchTwoFiles(self):
+ patchset = patch_path_filter.parse_svn_patch_set(RAW.PATCH + RAW.DIFFERENT)
+ self.assertEqual(2, len(patchset.filenames))
+ self.assertEqual('chrome/file.cc', patchset.filenames[0])
+ self.assertEqual('master/unittests/data/processes-summary.dat',
+ patchset.filenames[1])
+
+ def _verifyPatch(self, patchset):
+ self.assertEqual(1, len(patchset.filenames))
+ self.assertEqual('chrome/file.cc', patchset.filenames[0])
+ self.assertEqual('hh\n', patchset[0].dump()[-3:])
+
+
+if __name__ == '__main__':
+ unittest.main()
iannucci 2013/12/05 21:40:57 What do you think about a folder full of: tests/
kjellander_chromium 2013/12/10 20:46:02 I agree with you. I didn't feel confident that the

Powered by Google App Engine
This is Rietveld 408576698