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 sys | 10 import sys |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 ((['git', 'update-index', '--refresh', '-q'],), ''), | 92 ((['git', 'update-index', '--refresh', '-q'],), ''), |
93 ((['git', 'diff-index', 'HEAD'],), ''), | 93 ((['git', 'diff-index', 'HEAD'],), ''), |
94 ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), | 94 ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), |
95 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 95 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
96 ((['git', 'config', 'branch.master.merge'],), 'master'), | 96 ((['git', 'config', 'branch.master.merge'],), 'master'), |
97 ((['git', 'config', 'branch.master.remote'],), 'origin'), | 97 ((['git', 'config', 'branch.master.remote'],), 'origin'), |
98 ((['git', 'rev-parse', '--show-cdup'],), ''), | 98 ((['git', 'rev-parse', '--show-cdup'],), ''), |
99 ((['git', 'rev-parse', 'HEAD'],), '12345'), | 99 ((['git', 'rev-parse', 'HEAD'],), '12345'), |
100 ((['git', 'diff', '--name-status', '-r', 'master...', '.'],), | 100 ((['git', 'diff', '--name-status', '-r', 'master...', '.'],), |
101 'M\t.gitignore\n'), | 101 'M\t.gitignore\n'), |
102 ((['git', 'rev-parse', '--git-dir'],), '.git'), | |
103 ((['git', 'config', 'branch.master.rietveldissue'],), ''), | 102 ((['git', 'config', 'branch.master.rietveldissue'],), ''), |
104 ((['git', 'config', 'branch.master.rietveldpatchset'],), ''), | 103 ((['git', 'config', 'branch.master.rietveldpatchset'],), ''), |
105 ((['git', 'log', '--pretty=format:%s%n%n%b', 'master...'],), 'foo'), | 104 ((['git', 'log', '--pretty=format:%s%n%n%b', 'master...'],), 'foo'), |
106 ((['git', 'config', 'user.email'],), 'me@example.com'), | 105 ((['git', 'config', 'user.email'],), 'me@example.com'), |
107 ((['git', 'diff', '--no-ext-diff', '--stat', '-M', 'master...'],), | 106 ((['git', 'diff', '--no-ext-diff', '--stat', '-M', 'master...'],), |
108 '+dat'), | 107 '+dat'), |
109 ((['git', 'log', '--pretty=format:%s\n\n%b', 'master..'],), 'desc\n'), | 108 ((['git', 'log', '--pretty=format:%s\n\n%b', 'master..'],), 'desc\n'), |
110 ] | 109 ] |
111 | 110 |
112 @staticmethod | 111 @staticmethod |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 147 |
149 @classmethod | 148 @classmethod |
150 def _dcommit_calls_normal(cls): | 149 def _dcommit_calls_normal(cls): |
151 return [ | 150 return [ |
152 ((['git', 'rev-parse', '--show-cdup'],), ''), | 151 ((['git', 'rev-parse', '--show-cdup'],), ''), |
153 ((['git', 'rev-parse', 'HEAD'],), | 152 ((['git', 'rev-parse', 'HEAD'],), |
154 '00ff397798ea57439712ed7e04ab96e13969ef40'), | 153 '00ff397798ea57439712ed7e04ab96e13969ef40'), |
155 ((['git', 'diff', '--name-status', '-r', 'refs/remotes/origin/master...', | 154 ((['git', 'diff', '--name-status', '-r', 'refs/remotes/origin/master...', |
156 '.'],), | 155 '.'],), |
157 'M\tPRESUBMIT.py'), | 156 'M\tPRESUBMIT.py'), |
158 ((['git', 'rev-parse', '--git-dir'],), '.git'), | |
159 ((['git', 'config', 'branch.working.rietveldissue'],), '12345'), | 157 ((['git', 'config', 'branch.working.rietveldissue'],), '12345'), |
160 ((['git', 'config', 'branch.working.rietveldserver'],), | 158 ((['git', 'config', 'branch.working.rietveldserver'],), |
161 'codereview.example.com'), | 159 'codereview.example.com'), |
162 ((['git', 'config', 'branch.working.rietveldpatchset'],), '31137'), | 160 ((['git', 'config', 'branch.working.rietveldpatchset'],), '31137'), |
163 ((['git', 'config', 'user.email'],), 'author@example.com'), | 161 ((['git', 'config', 'user.email'],), 'author@example.com'), |
164 ((['git', 'config', 'rietveld.tree-status-url'],), ''), | 162 ((['git', 'config', 'rietveld.tree-status-url'],), ''), |
165 ] | 163 ] |
166 | 164 |
167 @classmethod | 165 @classmethod |
168 def _dcommit_calls_bypassed(cls): | 166 def _dcommit_calls_bypassed(cls): |
169 return [ | 167 return [ |
170 ((['git', 'rev-parse', '--git-dir'],), '.git'), | |
171 ((['git', 'config', 'branch.working.rietveldissue'],), '12345'), | 168 ((['git', 'config', 'branch.working.rietveldissue'],), '12345'), |
172 ((['git', 'config', 'branch.working.rietveldserver'],), | 169 ((['git', 'config', 'branch.working.rietveldserver'],), |
173 'codereview.example.com'), | 170 'codereview.example.com'), |
174 (('GitClHooksBypassedCommit', | 171 (('GitClHooksBypassedCommit', |
175 'Issue https://codereview.example.com/12345 bypassed hook when ' | 172 'Issue https://codereview.example.com/12345 bypassed hook when ' |
176 'committing'), None), | 173 'committing'), None), |
177 ] | 174 ] |
178 | 175 |
179 @classmethod | 176 @classmethod |
180 def _dcommit_calls_3(cls): | 177 def _dcommit_calls_3(cls): |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 ((['git', 'update-index', '--refresh', '-q'],), ''), | 326 ((['git', 'update-index', '--refresh', '-q'],), ''), |
330 ((['git', 'diff-index', 'HEAD'],), ''), | 327 ((['git', 'diff-index', 'HEAD'],), ''), |
331 ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), | 328 ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), |
332 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 329 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
333 ((['git', 'config', 'branch.master.merge'],), 'master'), | 330 ((['git', 'config', 'branch.master.merge'],), 'master'), |
334 ((['git', 'config', 'branch.master.remote'],), 'origin'), | 331 ((['git', 'config', 'branch.master.remote'],), 'origin'), |
335 ((['git', 'rev-parse', '--show-cdup'],), ''), | 332 ((['git', 'rev-parse', '--show-cdup'],), ''), |
336 ((['git', 'rev-parse', 'HEAD'],), '12345'), | 333 ((['git', 'rev-parse', 'HEAD'],), '12345'), |
337 ((['git', 'diff', '--name-status', '-r', 'master...', '.'],), | 334 ((['git', 'diff', '--name-status', '-r', 'master...', '.'],), |
338 'M\t.gitignore\n'), | 335 'M\t.gitignore\n'), |
339 ((['git', 'rev-parse', '--git-dir'],), '.git'), | |
340 ((['git', 'config', 'branch.master.rietveldissue'],), ''), | 336 ((['git', 'config', 'branch.master.rietveldissue'],), ''), |
341 ((['git', 'config', 'branch.master.rietveldpatchset'],), ''), | 337 ((['git', 'config', 'branch.master.rietveldpatchset'],), ''), |
342 ((['git', 'log', '--pretty=format:%s%n%n%b', 'master...'],), 'foo'), | 338 ((['git', 'log', '--pretty=format:%s%n%n%b', 'master...'],), 'foo'), |
343 ((['git', 'config', 'user.email'],), 'me@example.com'), | 339 ((['git', 'config', 'user.email'],), 'me@example.com'), |
344 ((['git', 'diff', '--no-ext-diff', '--stat', '-M', 'master...'],), | 340 ((['git', 'diff', '--no-ext-diff', '--stat', '-M', 'master...'],), |
345 '+dat'), | 341 '+dat'), |
346 ] | 342 ] |
347 | 343 |
348 @staticmethod | 344 @staticmethod |
349 def _gerrit_upload_calls(description, reviewers): | 345 def _gerrit_upload_calls(description, reviewers): |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 | 384 |
389 def test_gerrit_reviewer_multiple(self): | 385 def test_gerrit_reviewer_multiple(self): |
390 self._run_gerrit_reviewer_test( | 386 self._run_gerrit_reviewer_test( |
391 [], | 387 [], |
392 'desc\nTBR=reviewer@example.com\nBUG=\nR=another@example.com\n', | 388 'desc\nTBR=reviewer@example.com\nBUG=\nR=another@example.com\n', |
393 ['reviewer@example.com', 'another@example.com']) | 389 ['reviewer@example.com', 'another@example.com']) |
394 | 390 |
395 | 391 |
396 if __name__ == '__main__': | 392 if __name__ == '__main__': |
397 unittest.main() | 393 unittest.main() |
OLD | NEW |