| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Unit tests for git_cl.py.""" | 6 """Unit tests for git_cl.py.""" |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 import StringIO | 9 import StringIO |
| 10 import stat | 10 import stat |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 if find_copies: | 119 if find_copies: |
| 120 stat_call = ((['git', 'diff', '--no-ext-diff', '--stat', | 120 stat_call = ((['git', 'diff', '--no-ext-diff', '--stat', |
| 121 '--find-copies-harder', '-l100000', '-C'+similarity, | 121 '--find-copies-harder', '-l100000', '-C'+similarity, |
| 122 'fake_ancestor_sha'],), '+dat') | 122 'fake_ancestor_sha'],), '+dat') |
| 123 else: | 123 else: |
| 124 stat_call = ((['git', 'diff', '--no-ext-diff', '--stat', | 124 stat_call = ((['git', 'diff', '--no-ext-diff', '--stat', |
| 125 '-M'+similarity, 'fake_ancestor_sha'],), '+dat') | 125 '-M'+similarity, 'fake_ancestor_sha'],), '+dat') |
| 126 | 126 |
| 127 return [ | 127 return [ |
| 128 ((['git', 'config', 'gerrit.host'],), ''), | |
| 129 ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), | 128 ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), |
| 130 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 129 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
| 131 similarity_call, | 130 similarity_call, |
| 132 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 131 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
| 133 find_copies_call, | 132 find_copies_call, |
| 134 ((['git', 'update-index', '--refresh', '-q'],), ''), | 133 ((['git', 'update-index', '--refresh', '-q'],), ''), |
| 135 ((['git', 'diff-index', '--name-status', 'HEAD'],), ''), | 134 ((['git', 'diff-index', '--name-status', 'HEAD'],), ''), |
| 136 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 135 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
| 137 ((['git', 'config', 'branch.master.merge'],), 'master'), | 136 ((['git', 'config', 'branch.master.merge'],), 'master'), |
| 138 ((['git', 'config', 'branch.master.remote'],), 'origin'), | 137 ((['git', 'config', 'branch.master.remote'],), 'origin'), |
| 139 ((['git', 'merge-base', 'master', 'HEAD'],), 'fake_ancestor_sha'), | 138 ((['git', 'merge-base', 'master', 'HEAD'],), 'fake_ancestor_sha'), |
| 140 ] + cls._git_sanity_checks('fake_ancestor_sha', 'master') + [ | 139 ] + cls._git_sanity_checks('fake_ancestor_sha', 'master') + [ |
| 141 ((['git', 'rev-parse', '--show-cdup'],), ''), | 140 ((['git', 'rev-parse', '--show-cdup'],), ''), |
| 142 ((['git', 'rev-parse', 'HEAD'],), '12345'), | 141 ((['git', 'rev-parse', 'HEAD'],), '12345'), |
| 143 ((['git', 'diff', '--name-status', '-r', 'fake_ancestor_sha...', '.'],), | 142 ((['git', 'diff', '--name-status', '-r', 'fake_ancestor_sha...', '.'],), |
| 144 'M\t.gitignore\n'), | 143 'M\t.gitignore\n'), |
| 145 ((['git', 'config', 'branch.master.rietveldissue'],), ''), | 144 ((['git', 'config', 'branch.master.rietveldissue'],), ''), |
| 146 ((['git', 'config', 'branch.master.rietveldpatchset'],), ''), | 145 ((['git', 'config', 'branch.master.rietveldpatchset'],), ''), |
| 147 ((['git', 'log', '--pretty=format:%s%n%n%b', 'fake_ancestor_sha...'],), | 146 ((['git', 'log', '--pretty=format:%s%n%n%b', 'fake_ancestor_sha...'],), |
| 148 'foo'), | 147 'foo'), |
| 149 ((['git', 'config', 'user.email'],), 'me@example.com'), | 148 ((['git', 'config', 'user.email'],), 'me@example.com'), |
| 150 stat_call, | 149 stat_call, |
| 150 ((['git', 'config', 'gerrit.host'],), ''), |
| 151 ((['git', 'log', '--pretty=format:%s\n\n%b', 'fake_ancestor_sha..'],), | 151 ((['git', 'log', '--pretty=format:%s\n\n%b', 'fake_ancestor_sha..'],), |
| 152 'desc\n'), | 152 'desc\n'), |
| 153 ] | 153 ] |
| 154 | 154 |
| 155 @classmethod | 155 @classmethod |
| 156 def _git_upload_calls(cls): | 156 def _git_upload_calls(cls): |
| 157 return [ | 157 return [ |
| 158 ((['git', 'config', 'rietveld.cc'],), ''), | 158 ((['git', 'config', 'rietveld.cc'],), ''), |
| 159 ((['git', 'config', 'branch.master.base-url'],), ''), | 159 ((['git', 'config', 'branch.master.base-url'],), ''), |
| 160 ((['git', 'config', '--get-regexp', '^svn-remote\\.'],), | 160 ((['git', 'config', '--get-regexp', '^svn-remote\\.'],), |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 self.calls = ( | 425 self.calls = ( |
| 426 self._dcommit_calls_1() + | 426 self._dcommit_calls_1() + |
| 427 self._dcommit_calls_bypassed() + | 427 self._dcommit_calls_bypassed() + |
| 428 self._dcommit_calls_3()) | 428 self._dcommit_calls_3()) |
| 429 git_cl.main(['dcommit', '--bypass-hooks']) | 429 git_cl.main(['dcommit', '--bypass-hooks']) |
| 430 | 430 |
| 431 | 431 |
| 432 @classmethod | 432 @classmethod |
| 433 def _gerrit_base_calls(cls): | 433 def _gerrit_base_calls(cls): |
| 434 return [ | 434 return [ |
| 435 ((['git', 'config', 'gerrit.host'],), 'gerrit.example.com'), | |
| 436 ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), | 435 ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), |
| 437 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 436 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
| 438 ((['git', 'config', '--int', '--get', | 437 ((['git', 'config', '--int', '--get', |
| 439 'branch.master.git-cl-similarity'],), ''), | 438 'branch.master.git-cl-similarity'],), ''), |
| 440 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 439 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
| 441 ((['git', 'config', '--int', '--get', | 440 ((['git', 'config', '--int', '--get', |
| 442 'branch.master.git-find-copies'],), ''), | 441 'branch.master.git-find-copies'],), ''), |
| 443 ((['git', 'update-index', '--refresh', '-q'],), ''), | 442 ((['git', 'update-index', '--refresh', '-q'],), ''), |
| 444 ((['git', 'diff-index', '--name-status', 'HEAD'],), ''), | 443 ((['git', 'diff-index', '--name-status', 'HEAD'],), ''), |
| 445 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 444 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 457 'foo'), | 456 'foo'), |
| 458 ((['git', 'config', 'user.email'],), 'me@example.com'), | 457 ((['git', 'config', 'user.email'],), 'me@example.com'), |
| 459 ((['git', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', | 458 ((['git', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', |
| 460 '-l100000', '-C50', 'fake_ancestor_sha'],), | 459 '-l100000', '-C50', 'fake_ancestor_sha'],), |
| 461 '+dat'), | 460 '+dat'), |
| 462 ] | 461 ] |
| 463 | 462 |
| 464 @staticmethod | 463 @staticmethod |
| 465 def _gerrit_upload_calls(description, reviewers): | 464 def _gerrit_upload_calls(description, reviewers): |
| 466 calls = [ | 465 calls = [ |
| 466 ((['git', 'config', 'gerrit.host'],), 'gerrit.example.com'), |
| 467 ((['git', 'log', '--pretty=format:%s\n\n%b', 'fake_ancestor_sha..'],), | 467 ((['git', 'log', '--pretty=format:%s\n\n%b', 'fake_ancestor_sha..'],), |
| 468 description) | 468 description) |
| 469 ] | 469 ] |
| 470 if git_cl.CHANGE_ID not in description: | 470 if git_cl.CHANGE_ID not in description: |
| 471 calls += [ | 471 calls += [ |
| 472 ((['git', 'log', '--pretty=format:%s\n\n%b', 'fake_ancestor_sha..'],), | 472 ((['git', 'log', '--pretty=format:%s\n\n%b', 'fake_ancestor_sha..'],), |
| 473 description), | 473 description), |
| 474 ((['git', 'commit', '--amend', '-m', description],), | 474 ((['git', 'commit', '--amend', '-m', description],), |
| 475 ''), | 475 ''), |
| 476 ((['git', 'log', '--pretty=format:%s\n\n%b', 'fake_ancestor_sha..'],), | 476 ((['git', 'log', '--pretty=format:%s\n\n%b', 'fake_ancestor_sha..'],), |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 ((['git', 'config', 'rietveld.viewvc-url'],), ''), | 579 ((['git', 'config', 'rietveld.viewvc-url'],), ''), |
| 580 (('ViewVC URL:',), ''), | 580 (('ViewVC URL:',), ''), |
| 581 # DownloadHooks(True) | 581 # DownloadHooks(True) |
| 582 ((commit_msg_path, os.X_OK,), True), | 582 ((commit_msg_path, os.X_OK,), True), |
| 583 ] | 583 ] |
| 584 git_cl.main(['config']) | 584 git_cl.main(['config']) |
| 585 | 585 |
| 586 | 586 |
| 587 if __name__ == '__main__': | 587 if __name__ == '__main__': |
| 588 unittest.main() | 588 unittest.main() |
| OLD | NEW |