| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 ((['git', 'config', 'branch.master.remote'],), 'origin'), | 108 ((['git', 'config', 'branch.master.remote'],), 'origin'), |
| 109 ((['git', 'rev-parse', '--show-cdup'],), ''), | 109 ((['git', 'rev-parse', '--show-cdup'],), ''), |
| 110 ((['git', 'rev-parse', 'HEAD'],), '12345'), | 110 ((['git', 'rev-parse', 'HEAD'],), '12345'), |
| 111 ((['git', 'diff', '--name-status', '-r', 'master...', '.'],), | 111 ((['git', 'diff', '--name-status', '-r', 'master...', '.'],), |
| 112 'M\t.gitignore\n'), | 112 'M\t.gitignore\n'), |
| 113 ((['git', 'config', 'branch.master.rietveldissue'],), ''), | 113 ((['git', 'config', 'branch.master.rietveldissue'],), ''), |
| 114 ((['git', 'config', 'branch.master.rietveldpatchset'],), ''), | 114 ((['git', 'config', 'branch.master.rietveldpatchset'],), ''), |
| 115 ((['git', 'log', '--pretty=format:%s%n%n%b', 'master...'],), 'foo'), | 115 ((['git', 'log', '--pretty=format:%s%n%n%b', 'master...'],), 'foo'), |
| 116 ((['git', 'config', 'user.email'],), 'me@example.com'), | 116 ((['git', 'config', 'user.email'],), 'me@example.com'), |
| 117 ((['git', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', | 117 ((['git', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', |
| 118 '-l100000', 'master...'],), | 118 '-C50', '-l100000', 'master...'],), |
| 119 '+dat'), | 119 '+dat'), |
| 120 ((['git', 'log', '--pretty=format:%s\n\n%b', 'master..'],), 'desc\n'), | 120 ((['git', 'log', '--pretty=format:%s\n\n%b', 'master..'],), 'desc\n'), |
| 121 ] | 121 ] |
| 122 | 122 |
| 123 @staticmethod | 123 @staticmethod |
| 124 def _git_upload_calls(): | 124 def _git_upload_calls(): |
| 125 return [ | 125 return [ |
| 126 ((['git', 'config', 'rietveld.cc'],), ''), | 126 ((['git', 'config', 'rietveld.cc'],), ''), |
| 127 ((['git', 'config', 'branch.master.base-url'],), ''), | 127 ((['git', 'config', 'branch.master.base-url'],), ''), |
| 128 ((['git', 'config', '--get-regexp', '^svn-remote\\.'],), | 128 ((['git', 'config', '--get-regexp', '^svn-remote\\.'],), |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 'codereview.example.com'), | 186 'codereview.example.com'), |
| 187 (('GitClHooksBypassedCommit', | 187 (('GitClHooksBypassedCommit', |
| 188 'Issue https://codereview.example.com/12345 bypassed hook when ' | 188 'Issue https://codereview.example.com/12345 bypassed hook when ' |
| 189 'committing'), None), | 189 'committing'), None), |
| 190 ] | 190 ] |
| 191 | 191 |
| 192 @classmethod | 192 @classmethod |
| 193 def _dcommit_calls_3(cls): | 193 def _dcommit_calls_3(cls): |
| 194 return [ | 194 return [ |
| 195 ((['git', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', | 195 ((['git', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', |
| 196 '-l100000', 'refs/remotes/origin/master', 'refs/heads/working'],), | 196 '-C50', '-l100000', 'refs/remotes/origin/master', |
| 197 'refs/heads/working'],), |
| 197 (' PRESUBMIT.py | 2 +-\n' | 198 (' PRESUBMIT.py | 2 +-\n' |
| 198 ' 1 files changed, 1 insertions(+), 1 deletions(-)\n')), | 199 ' 1 files changed, 1 insertions(+), 1 deletions(-)\n')), |
| 199 (('About to commit; enter to confirm.',), None), | 200 (('About to commit; enter to confirm.',), None), |
| 200 ((['git', 'show-ref', '--quiet', '--verify', | 201 ((['git', 'show-ref', '--quiet', '--verify', |
| 201 'refs/heads/git-cl-commit'],), | 202 'refs/heads/git-cl-commit'],), |
| 202 (('', None), 0)), | 203 (('', None), 0)), |
| 203 ((['git', 'branch', '-D', 'git-cl-commit'],), ''), | 204 ((['git', 'branch', '-D', 'git-cl-commit'],), ''), |
| 204 ((['git', 'show-ref', '--quiet', '--verify', | 205 ((['git', 'show-ref', '--quiet', '--verify', |
| 205 'refs/heads/git-cl-cherry-pick'],), ''), | 206 'refs/heads/git-cl-cherry-pick'],), ''), |
| 206 ((['git', 'rev-parse', '--show-cdup'],), '\n'), | 207 ((['git', 'rev-parse', '--show-cdup'],), '\n'), |
| 207 ((['git', 'checkout', '-q', '-b', 'git-cl-commit'],), ''), | 208 ((['git', 'checkout', '-q', '-b', 'git-cl-commit'],), ''), |
| 208 ((['git', 'reset', '--soft', 'refs/remotes/origin/master'],), ''), | 209 ((['git', 'reset', '--soft', 'refs/remotes/origin/master'],), ''), |
| 209 ((['git', 'commit', '-m', | 210 ((['git', 'commit', '-m', |
| 210 'Issue: 12345\n\nReview URL: https://codereview.example.com/12345'],), | 211 'Issue: 12345\n\nReview URL: https://codereview.example.com/12345'],), |
| 211 ''), | 212 ''), |
| 212 ((['git', 'svn', 'dcommit', '--no-rebase', '--rmdir'],), (('', None), 0)), | 213 ((['git', 'svn', 'dcommit', '-C50', '--no-rebase', '--rmdir'],), |
| 214 (('', None), 0)), |
| 213 ((['git', 'checkout', '-q', 'working'],), ''), | 215 ((['git', 'checkout', '-q', 'working'],), ''), |
| 214 ((['git', 'branch', '-D', 'git-cl-commit'],), ''), | 216 ((['git', 'branch', '-D', 'git-cl-commit'],), ''), |
| 215 ] | 217 ] |
| 216 | 218 |
| 217 @staticmethod | 219 @staticmethod |
| 218 def _cmd_line(description, args): | 220 def _cmd_line(description, args): |
| 219 """Returns the upload command line passed to upload.RealMain().""" | 221 """Returns the upload command line passed to upload.RealMain().""" |
| 220 return [ | 222 return [ |
| 221 'upload', '--assume_yes', '--server', | 223 'upload', '--assume_yes', '--server', |
| 222 'https://codereview.example.com', | 224 'https://codereview.example.com', |
| 223 '--message', description | 225 '--message', description |
| 224 ] + args + [ | 226 ] + args + [ |
| 225 '--cc', 'joe@example.com', | 227 '--cc', 'joe@example.com', |
| 228 '--git_similarity', '50', |
| 226 'master...' | 229 'master...' |
| 227 ] | 230 ] |
| 228 | 231 |
| 229 def _run_reviewer_test( | 232 def _run_reviewer_test( |
| 230 self, | 233 self, |
| 231 upload_args, | 234 upload_args, |
| 232 expected_description, | 235 expected_description, |
| 233 returned_description, | 236 returned_description, |
| 234 final_description, | 237 final_description, |
| 235 reviewers): | 238 reviewers): |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 ((['git', 'config', 'branch.master.remote'],), 'origin'), | 350 ((['git', 'config', 'branch.master.remote'],), 'origin'), |
| 348 ((['git', 'rev-parse', '--show-cdup'],), ''), | 351 ((['git', 'rev-parse', '--show-cdup'],), ''), |
| 349 ((['git', 'rev-parse', 'HEAD'],), '12345'), | 352 ((['git', 'rev-parse', 'HEAD'],), '12345'), |
| 350 ((['git', 'diff', '--name-status', '-r', 'master...', '.'],), | 353 ((['git', 'diff', '--name-status', '-r', 'master...', '.'],), |
| 351 'M\t.gitignore\n'), | 354 'M\t.gitignore\n'), |
| 352 ((['git', 'config', 'branch.master.rietveldissue'],), ''), | 355 ((['git', 'config', 'branch.master.rietveldissue'],), ''), |
| 353 ((['git', 'config', 'branch.master.rietveldpatchset'],), ''), | 356 ((['git', 'config', 'branch.master.rietveldpatchset'],), ''), |
| 354 ((['git', 'log', '--pretty=format:%s%n%n%b', 'master...'],), 'foo'), | 357 ((['git', 'log', '--pretty=format:%s%n%n%b', 'master...'],), 'foo'), |
| 355 ((['git', 'config', 'user.email'],), 'me@example.com'), | 358 ((['git', 'config', 'user.email'],), 'me@example.com'), |
| 356 ((['git', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', | 359 ((['git', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', |
| 357 '-l100000', 'master...'],), | 360 '-C50', '-l100000', 'master...'],), |
| 358 '+dat'), | 361 '+dat'), |
| 359 ] | 362 ] |
| 360 | 363 |
| 361 @staticmethod | 364 @staticmethod |
| 362 def _gerrit_upload_calls(description, reviewers): | 365 def _gerrit_upload_calls(description, reviewers): |
| 363 calls = [ | 366 calls = [ |
| 364 ((['git', 'log', '--pretty=format:%s\n\n%b', 'master..'],), | 367 ((['git', 'log', '--pretty=format:%s\n\n%b', 'master..'],), |
| 365 description), | 368 description), |
| 366 ((['git', 'config', 'rietveld.cc'],), '') | 369 ((['git', 'config', 'rietveld.cc'],), '') |
| 367 ] | 370 ] |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 ((['git', 'config', 'rietveld.viewvc-url'],), ''), | 461 ((['git', 'config', 'rietveld.viewvc-url'],), ''), |
| 459 (('ViewVC URL:',), ''), | 462 (('ViewVC URL:',), ''), |
| 460 # DownloadHooks(True) | 463 # DownloadHooks(True) |
| 461 ((commit_msg_path, os.X_OK,), True), | 464 ((commit_msg_path, os.X_OK,), True), |
| 462 ] | 465 ] |
| 463 git_cl.main(['config']) | 466 git_cl.main(['config']) |
| 464 | 467 |
| 465 | 468 |
| 466 if __name__ == '__main__': | 469 if __name__ == '__main__': |
| 467 unittest.main() | 470 unittest.main() |
| OLD | NEW |