OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # coding: utf-8 | 2 # coding: utf-8 |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Unit tests for patch.py.""" | 7 """Unit tests for patch.py.""" |
8 | 8 |
9 import logging | 9 import logging |
10 import os | 10 import os |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 def testDifferent(self): | 76 def testDifferent(self): |
77 name = 'master/unittests/data/processes-summary.dat' | 77 name = 'master/unittests/data/processes-summary.dat' |
78 p = patch.FilePatchDiff(name, RAW.DIFFERENT, []) | 78 p = patch.FilePatchDiff(name, RAW.DIFFERENT, []) |
79 self._check_patch(p, name, RAW.DIFFERENT, nb_hunks=1) | 79 self._check_patch(p, name, RAW.DIFFERENT, nb_hunks=1) |
80 | 80 |
81 def testFilePatchDiffHeaderMode(self): | 81 def testFilePatchDiffHeaderMode(self): |
82 p = patch.FilePatchDiff('git_cl/git-cl', GIT.MODE_EXE, []) | 82 p = patch.FilePatchDiff('git_cl/git-cl', GIT.MODE_EXE, []) |
83 self._check_patch( | 83 self._check_patch( |
84 p, 'git_cl/git-cl', GIT.MODE_EXE, is_git_diff=True, patchlevel=1, | 84 p, 'git_cl/git-cl', GIT.MODE_EXE, is_git_diff=True, patchlevel=1, |
85 svn_properties=[('svn:executable', '*')], nb_hunks=0) | 85 svn_properties=[('svn:executable', '.')], nb_hunks=0) |
86 | 86 |
87 def testFilePatchDiffHeaderModeIndex(self): | 87 def testFilePatchDiffHeaderModeIndex(self): |
88 p = patch.FilePatchDiff('git_cl/git-cl', GIT.MODE_EXE_JUNK, []) | 88 p = patch.FilePatchDiff('git_cl/git-cl', GIT.MODE_EXE_JUNK, []) |
89 self._check_patch( | 89 self._check_patch( |
90 p, 'git_cl/git-cl', GIT.MODE_EXE_JUNK, is_git_diff=True, patchlevel=1, | 90 p, 'git_cl/git-cl', GIT.MODE_EXE_JUNK, is_git_diff=True, patchlevel=1, |
91 svn_properties=[('svn:executable', '*')], nb_hunks=0) | 91 svn_properties=[('svn:executable', '.')], nb_hunks=0) |
92 | 92 |
93 def testFilePatchDiffHeaderNotExecutable(self): | 93 def testFilePatchDiffHeaderNotExecutable(self): |
94 p = patch.FilePatchDiff( | 94 p = patch.FilePatchDiff( |
95 'build/android/ant/create.js', GIT.NEW_NOT_EXECUTABLE, []) | 95 'build/android/ant/create.js', GIT.NEW_NOT_EXECUTABLE, []) |
96 self._check_patch( | 96 self._check_patch( |
97 p, 'build/android/ant/create.js', GIT.NEW_NOT_EXECUTABLE, | 97 p, 'build/android/ant/create.js', GIT.NEW_NOT_EXECUTABLE, |
98 is_git_diff=True, patchlevel=1, is_new=True, | 98 is_git_diff=True, patchlevel=1, is_new=True, |
99 nb_hunks=1) | 99 nb_hunks=1) |
100 | 100 |
101 def testFilePatchDiffSvnNew(self): | 101 def testFilePatchDiffSvnNew(self): |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 | 325 |
326 def testGitNewExe(self): | 326 def testGitNewExe(self): |
327 p = patch.FilePatchDiff('natsort_test.py', GIT.NEW_EXE, []) | 327 p = patch.FilePatchDiff('natsort_test.py', GIT.NEW_EXE, []) |
328 self._check_patch( | 328 self._check_patch( |
329 p, | 329 p, |
330 'natsort_test.py', | 330 'natsort_test.py', |
331 GIT.NEW_EXE, | 331 GIT.NEW_EXE, |
332 is_new=True, | 332 is_new=True, |
333 is_git_diff=True, | 333 is_git_diff=True, |
334 patchlevel=1, | 334 patchlevel=1, |
335 svn_properties=[('svn:executable', '*')], | 335 svn_properties=[('svn:executable', '.')], |
336 nb_hunks=1) | 336 nb_hunks=1) |
337 | 337 |
338 def testGitNewMode(self): | 338 def testGitNewMode(self): |
339 p = patch.FilePatchDiff('natsort_test.py', GIT.NEW_MODE, []) | 339 p = patch.FilePatchDiff('natsort_test.py', GIT.NEW_MODE, []) |
340 self._check_patch( | 340 self._check_patch( |
341 p, 'natsort_test.py', GIT.NEW_MODE, is_new=True, is_git_diff=True, | 341 p, 'natsort_test.py', GIT.NEW_MODE, is_new=True, is_git_diff=True, |
342 patchlevel=1, nb_hunks=1) | 342 patchlevel=1, nb_hunks=1) |
343 | 343 |
344 def testPatchsetOrder(self): | 344 def testPatchsetOrder(self): |
345 # Deletes must be last. | 345 # Deletes must be last. |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 self.fail() | 547 self.fail() |
548 except patch.UnsupportedPatchFormat: | 548 except patch.UnsupportedPatchFormat: |
549 pass | 549 pass |
550 | 550 |
551 | 551 |
552 if __name__ == '__main__': | 552 if __name__ == '__main__': |
553 logging.basicConfig(level= | 553 logging.basicConfig(level= |
554 [logging.WARNING, logging.INFO, logging.DEBUG][ | 554 [logging.WARNING, logging.INFO, logging.DEBUG][ |
555 min(2, sys.argv.count('-v'))]) | 555 min(2, sys.argv.count('-v'))]) |
556 unittest.main() | 556 unittest.main() |
OLD | NEW |