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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 ((['git', 'config', 'branch.master.merge'],), 'master'), | 107 ((['git', 'config', 'branch.master.merge'],), 'master'), |
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', '-M', 'master...'],), | 117 ((['git', 'diff', '--no-ext-diff', '--stat', '-C', '-C', 'master...'],), |
118 '+dat'), | 118 '+dat'), |
119 ((['git', 'log', '--pretty=format:%s\n\n%b', 'master..'],), 'desc\n'), | 119 ((['git', 'log', '--pretty=format:%s\n\n%b', 'master..'],), 'desc\n'), |
120 ] | 120 ] |
121 | 121 |
122 @staticmethod | 122 @staticmethod |
123 def _git_upload_calls(): | 123 def _git_upload_calls(): |
124 return [ | 124 return [ |
125 ((['git', 'config', 'rietveld.cc'],), ''), | 125 ((['git', 'config', 'rietveld.cc'],), ''), |
126 ((['git', 'config', 'branch.master.base-url'],), ''), | 126 ((['git', 'config', 'branch.master.base-url'],), ''), |
127 ((['git', 'config', '--get-regexp', '^svn-remote\\.'],), | 127 ((['git', 'config', '--get-regexp', '^svn-remote\\.'],), |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 210 |
211 @staticmethod | 211 @staticmethod |
212 def _cmd_line(description, args): | 212 def _cmd_line(description, args): |
213 """Returns the upload command line passed to upload.RealMain().""" | 213 """Returns the upload command line passed to upload.RealMain().""" |
214 return [ | 214 return [ |
215 'upload', '--assume_yes', '--server', | 215 'upload', '--assume_yes', '--server', |
216 'https://codereview.example.com', | 216 'https://codereview.example.com', |
217 '--message', description | 217 '--message', description |
218 ] + args + [ | 218 ] + args + [ |
219 '--cc', 'joe@example.com', | 219 '--cc', 'joe@example.com', |
220 'master...' | 220 'master...', '--', '-C', |
221 ] | 221 ] |
222 | 222 |
223 def _run_reviewer_test( | 223 def _run_reviewer_test( |
224 self, | 224 self, |
225 upload_args, | 225 upload_args, |
226 expected_description, | 226 expected_description, |
227 returned_description, | 227 returned_description, |
228 final_description, | 228 final_description, |
229 reviewers): | 229 reviewers): |
230 """Generic reviewer test framework.""" | 230 """Generic reviewer test framework.""" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 ((['git', 'config', 'branch.master.merge'],), 'master'), | 340 ((['git', 'config', 'branch.master.merge'],), 'master'), |
341 ((['git', 'config', 'branch.master.remote'],), 'origin'), | 341 ((['git', 'config', 'branch.master.remote'],), 'origin'), |
342 ((['git', 'rev-parse', '--show-cdup'],), ''), | 342 ((['git', 'rev-parse', '--show-cdup'],), ''), |
343 ((['git', 'rev-parse', 'HEAD'],), '12345'), | 343 ((['git', 'rev-parse', 'HEAD'],), '12345'), |
344 ((['git', 'diff', '--name-status', '-r', 'master...', '.'],), | 344 ((['git', 'diff', '--name-status', '-r', 'master...', '.'],), |
345 'M\t.gitignore\n'), | 345 'M\t.gitignore\n'), |
346 ((['git', 'config', 'branch.master.rietveldissue'],), ''), | 346 ((['git', 'config', 'branch.master.rietveldissue'],), ''), |
347 ((['git', 'config', 'branch.master.rietveldpatchset'],), ''), | 347 ((['git', 'config', 'branch.master.rietveldpatchset'],), ''), |
348 ((['git', 'log', '--pretty=format:%s%n%n%b', 'master...'],), 'foo'), | 348 ((['git', 'log', '--pretty=format:%s%n%n%b', 'master...'],), 'foo'), |
349 ((['git', 'config', 'user.email'],), 'me@example.com'), | 349 ((['git', 'config', 'user.email'],), 'me@example.com'), |
350 ((['git', 'diff', '--no-ext-diff', '--stat', '-M', 'master...'],), | 350 ((['git', 'diff', '--no-ext-diff', '--stat', '-C', '-C', 'master...'],), |
351 '+dat'), | 351 '+dat'), |
352 ] | 352 ] |
353 | 353 |
354 @staticmethod | 354 @staticmethod |
355 def _gerrit_upload_calls(description, reviewers): | 355 def _gerrit_upload_calls(description, reviewers): |
356 calls = [ | 356 calls = [ |
357 ((['git', 'log', '--pretty=format:%s\n\n%b', 'master..'],), | 357 ((['git', 'log', '--pretty=format:%s\n\n%b', 'master..'],), |
358 description), | 358 description), |
359 ((['git', 'config', 'rietveld.cc'],), '') | 359 ((['git', 'config', 'rietveld.cc'],), '') |
360 ] | 360 ] |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 ((['git', 'config', 'rietveld.viewvc-url'],), ''), | 450 ((['git', 'config', 'rietveld.viewvc-url'],), ''), |
451 (('ViewVC URL:',), ''), | 451 (('ViewVC URL:',), ''), |
452 # DownloadHooks(True) | 452 # DownloadHooks(True) |
453 (('/usr/local/src/.git/hooks/commit-msg', os.X_OK,), True), | 453 (('/usr/local/src/.git/hooks/commit-msg', os.X_OK,), True), |
454 ] | 454 ] |
455 git_cl.main(['config']) | 455 git_cl.main(['config']) |
456 | 456 |
457 | 457 |
458 if __name__ == '__main__': | 458 if __name__ == '__main__': |
459 unittest.main() | 459 unittest.main() |
OLD | NEW |