Chromium Code Reviews| 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
|