Chromium Code Reviews| 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 checkout.py.""" | 6 """Unit tests for checkout.py.""" |
| 7 | 7 |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import shutil | 10 import shutil |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 | 25 |
| 26 # pass -v to enable it. | 26 # pass -v to enable it. |
| 27 DEBUGGING = False | 27 DEBUGGING = False |
| 28 | 28 |
| 29 # A patch that will fail to apply. | 29 # A patch that will fail to apply. |
| 30 BAD_PATCH = ''.join( | 30 BAD_PATCH = ''.join( |
| 31 [l for l in GIT.PATCH.splitlines(True) if l.strip() != 'e']) | 31 [l for l in GIT.PATCH.splitlines(True) if l.strip() != 'e']) |
| 32 | 32 |
| 33 | 33 |
| 34 class FakeRepos(fake_repos.FakeReposBase): | 34 class FakeRepos(fake_repos.FakeReposBase): |
| 35 TEST_GIT_REPO = 'repo_1' | |
| 36 | |
| 35 def populateSvn(self): | 37 def populateSvn(self): |
| 36 """Creates a few revisions of changes files.""" | 38 """Creates a few revisions of changes files.""" |
| 37 subprocess2.check_call( | 39 subprocess2.check_call( |
| 38 ['svn', 'checkout', self.svn_base, self.svn_checkout, '-q', | 40 ['svn', 'checkout', self.svn_base, self.svn_checkout, '-q', |
| 39 '--non-interactive', '--no-auth-cache', | 41 '--non-interactive', '--no-auth-cache', |
| 40 '--username', self.USERS[0][0], '--password', self.USERS[0][1]]) | 42 '--username', self.USERS[0][0], '--password', self.USERS[0][1]]) |
| 41 assert os.path.isdir(os.path.join(self.svn_checkout, '.svn')) | 43 assert os.path.isdir(os.path.join(self.svn_checkout, '.svn')) |
| 42 self._commit_svn(self._tree_1()) | 44 self._commit_svn(self._svn_tree_1()) |
| 43 self._commit_svn(self._tree_2()) | 45 self._commit_svn(self._svn_tree_2()) |
| 46 | |
| 47 def populateGit(self): | |
| 48 """Creates a few revisions of changes files.""" | |
| 49 self._commit_git(self.TEST_GIT_REPO, self._git_tree()) | |
| 50 # pylint: disable=C0301 | |
| 51 # Fix for the remote rejected error. For more details see: | |
| 52 # http://stackoverflow.com/questions/2816369/git-push-error-remote-rejected- master-master-branch-is-currently-checked | |
|
M-A Ruel
2013/09/03 13:10:16
# http://stackoverflow.com/questions/2816369/git-p
rmistry
2013/09/03 15:46:28
Cool, thanks.
| |
| 53 subprocess2.check_output( | |
| 54 ['git', '--git-dir', | |
| 55 os.path.join(self.git_root, self.TEST_GIT_REPO, '.git'), | |
| 56 'config', '--bool', 'core.bare', 'true']) | |
| 57 | |
| 58 assert os.path.isdir( | |
| 59 os.path.join(self.git_root, self.TEST_GIT_REPO, '.git')) | |
| 44 | 60 |
| 45 @staticmethod | 61 @staticmethod |
| 46 def _tree_1(): | 62 def _git_tree(): |
| 63 fs = {} | |
| 64 fs['origin'] = 'git@1' | |
| 65 fs['extra'] = 'dummy\n' # new | |
| 66 fs['codereview.settings'] = ( | |
| 67 '# Test data\n' | |
| 68 'bar: pouet\n') | |
| 69 fs['chrome/file.cc'] = ( | |
| 70 'a\n' | |
| 71 'bb\n' | |
| 72 'ccc\n' | |
| 73 'dd\n' | |
| 74 'e\n' | |
| 75 'ff\n' | |
| 76 'ggg\n' | |
| 77 'hh\n' | |
| 78 'i\n' | |
| 79 'jj\n' | |
| 80 'kkk\n' | |
| 81 'll\n' | |
| 82 'm\n' | |
| 83 'nn\n' | |
| 84 'ooo\n' | |
| 85 'pp\n' | |
| 86 'q\n') | |
| 87 fs['chromeos/views/DOMui_menu_widget.h'] = ( | |
| 88 '// Copyright (c) 2010\n' | |
| 89 '// Use of this source code\n' | |
| 90 '// found in the LICENSE file.\n' | |
| 91 '\n' | |
| 92 '#ifndef DOM\n' | |
| 93 '#define DOM\n' | |
| 94 '#pragma once\n' | |
| 95 '\n' | |
| 96 '#include <string>\n' | |
| 97 '#endif\n') | |
| 98 return fs | |
| 99 | |
| 100 @staticmethod | |
| 101 def _svn_tree_1(): | |
| 47 fs = {} | 102 fs = {} |
| 48 fs['trunk/origin'] = 'svn@1' | 103 fs['trunk/origin'] = 'svn@1' |
| 49 fs['trunk/codereview.settings'] = ( | 104 fs['trunk/codereview.settings'] = ( |
| 50 '# Test data\n' | 105 '# Test data\n' |
| 51 'bar: pouet\n') | 106 'bar: pouet\n') |
| 52 fs['trunk/chrome/file.cc'] = ( | 107 fs['trunk/chrome/file.cc'] = ( |
| 53 'a\n' | 108 'a\n' |
| 54 'bb\n' | 109 'bb\n' |
| 55 'ccc\n' | 110 'ccc\n' |
| 56 'dd\n' | 111 'dd\n' |
| 57 'e\n' | 112 'e\n' |
| 58 'ff\n' | 113 'ff\n' |
| 59 'ggg\n' | 114 'ggg\n' |
| 60 'hh\n' | 115 'hh\n' |
| 61 'i\n' | 116 'i\n' |
| 62 'jj\n' | 117 'jj\n' |
| 63 'kkk\n' | 118 'kkk\n' |
| 64 'll\n' | 119 'll\n' |
| 65 'm\n' | 120 'm\n' |
| 66 'nn\n' | 121 'nn\n' |
| 67 'ooo\n' | 122 'ooo\n' |
| 68 'pp\n' | 123 'pp\n' |
| 69 'q\n') | 124 'q\n') |
| 70 return fs | 125 return fs |
| 71 | 126 |
| 72 @classmethod | 127 @classmethod |
| 73 def _tree_2(cls): | 128 def _svn_tree_2(cls): |
| 74 fs = cls._tree_1() | 129 fs = cls._svn_tree_1() |
| 75 fs['trunk/origin'] = 'svn@2\n' | 130 fs['trunk/origin'] = 'svn@2\n' |
| 76 fs['trunk/extra'] = 'dummy\n' | 131 fs['trunk/extra'] = 'dummy\n' |
| 77 fs['trunk/bin_file'] = '\x00' | 132 fs['trunk/bin_file'] = '\x00' |
| 78 fs['trunk/chromeos/views/DOMui_menu_widget.h'] = ( | 133 fs['trunk/chromeos/views/DOMui_menu_widget.h'] = ( |
| 79 '// Copyright (c) 2010\n' | 134 '// Copyright (c) 2010\n' |
| 80 '// Use of this source code\n' | 135 '// Use of this source code\n' |
| 81 '// found in the LICENSE file.\n' | 136 '// found in the LICENSE file.\n' |
| 82 '\n' | 137 '\n' |
| 83 '#ifndef DOM\n' | 138 '#ifndef DOM\n' |
| 84 '#define DOM\n' | 139 '#define DOM\n' |
| 85 '#pragma once\n' | 140 '#pragma once\n' |
| 86 '\n' | 141 '\n' |
| 87 '#include <string>\n' | 142 '#include <string>\n' |
| 88 '#endif\n') | 143 '#endif\n') |
| 89 return fs | 144 return fs |
| 90 | 145 |
| 91 def populateGit(self): | |
| 92 raise NotImplementedError() | |
| 93 | |
| 94 | 146 |
| 95 # pylint: disable=R0201 | 147 # pylint: disable=R0201 |
| 96 class BaseTest(fake_repos.FakeReposTestBase): | 148 class BaseTest(fake_repos.FakeReposTestBase): |
| 97 name = 'foo' | 149 name = 'foo' |
| 98 FAKE_REPOS_CLASS = FakeRepos | 150 FAKE_REPOS_CLASS = FakeRepos |
| 99 is_read_only = False | 151 is_read_only = False |
| 100 | 152 |
| 101 def setUp(self): | 153 def setUp(self): |
| 102 # Need to enforce subversion_config first. | 154 # Need to enforce subversion_config first. |
| 103 checkout.SvnMixIn.svn_config_dir = os.path.join( | 155 checkout.SvnMixIn.svn_config_dir = os.path.join( |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 120 def get_patches(self): | 172 def get_patches(self): |
| 121 return patch.PatchSet([ | 173 return patch.PatchSet([ |
| 122 patch.FilePatchDiff('new_dir/subdir/new_file', GIT.NEW_SUBDIR, []), | 174 patch.FilePatchDiff('new_dir/subdir/new_file', GIT.NEW_SUBDIR, []), |
| 123 patch.FilePatchDiff('chrome/file.cc', GIT.PATCH, []), | 175 patch.FilePatchDiff('chrome/file.cc', GIT.PATCH, []), |
| 124 # TODO(maruel): Test with is_new == False. | 176 # TODO(maruel): Test with is_new == False. |
| 125 patch.FilePatchBinary('bin_file', '\x00', [], is_new=True), | 177 patch.FilePatchBinary('bin_file', '\x00', [], is_new=True), |
| 126 patch.FilePatchDelete('extra', False), | 178 patch.FilePatchDelete('extra', False), |
| 127 ]) | 179 ]) |
| 128 | 180 |
| 129 def get_trunk(self, modified): | 181 def get_trunk(self, modified): |
| 130 tree = {} | 182 raise NotImplementedError() |
| 131 subroot = 'trunk/' | |
| 132 for k, v in self.FAKE_REPOS.svn_revs[-1].iteritems(): | |
| 133 if k.startswith(subroot): | |
| 134 f = k[len(subroot):] | |
| 135 assert f not in tree | |
| 136 tree[f] = v | |
| 137 | 183 |
| 138 if modified: | 184 def _check_base(self, co, root, expected): |
| 139 content_lines = tree['chrome/file.cc'].splitlines(True) | 185 raise NotImplementedError() |
| 140 tree['chrome/file.cc'] = ''.join( | |
| 141 content_lines[0:5] + ['FOO!\n'] + content_lines[5:]) | |
| 142 del tree['extra'] | |
| 143 tree['new_dir/subdir/new_file'] = 'A new file\nshould exist.\n' | |
| 144 return tree | |
| 145 | |
| 146 def _check_base(self, co, root, git, expected): | |
| 147 read_only = isinstance(co, checkout.ReadOnlyCheckout) | |
| 148 self.assertEquals(not read_only, bool(expected)) | |
| 149 self.assertEquals(read_only, self.is_read_only) | |
| 150 if not read_only: | |
| 151 self.FAKE_REPOS.svn_dirty = True | |
| 152 | |
| 153 self.assertEquals(root, co.project_path) | |
| 154 self.assertEquals(self.previous_log['revision'], co.prepare(None)) | |
| 155 self.assertEquals('pouet', co.get_settings('bar')) | |
| 156 self.assertTree(self.get_trunk(False), root) | |
| 157 patches = self.get_patches() | |
| 158 co.apply_patch(patches) | |
| 159 self.assertEquals( | |
| 160 ['bin_file', 'chrome/file.cc', 'new_dir/subdir/new_file', 'extra'], | |
| 161 patches.filenames) | |
| 162 | |
| 163 if git: | |
| 164 # Hackish to verify _branches() internal function. | |
| 165 # pylint: disable=W0212 | |
| 166 self.assertEquals( | |
| 167 (['master', 'working_branch'], 'working_branch'), | |
| 168 co._branches()) | |
| 169 | |
| 170 # Verify that the patch is applied even for read only checkout. | |
| 171 self.assertTree(self.get_trunk(True), root) | |
| 172 fake_author = self.FAKE_REPOS.USERS[1][0] | |
| 173 revision = co.commit(u'msg', fake_author) | |
| 174 # Nothing changed. | |
| 175 self.assertTree(self.get_trunk(True), root) | |
| 176 | |
| 177 if read_only: | |
| 178 self.assertEquals('FAKE', revision) | |
| 179 self.assertEquals(self.previous_log['revision'], co.prepare(None)) | |
| 180 # Changes should be reverted now. | |
| 181 self.assertTree(self.get_trunk(False), root) | |
| 182 expected = self.previous_log | |
| 183 else: | |
| 184 self.assertEquals(self.previous_log['revision'] + 1, revision) | |
| 185 self.assertEquals(self.previous_log['revision'] + 1, co.prepare(None)) | |
| 186 self.assertTree(self.get_trunk(True), root) | |
| 187 expected = expected.copy() | |
| 188 expected['msg'] = 'msg' | |
| 189 expected['revision'] = self.previous_log['revision'] + 1 | |
| 190 expected.setdefault('author', fake_author) | |
| 191 | |
| 192 actual = self._log() | |
| 193 self.assertEquals(expected, actual) | |
| 194 | 186 |
| 195 def _check_exception(self, co, err_msg): | 187 def _check_exception(self, co, err_msg): |
| 196 co.prepare(None) | 188 co.prepare(None) |
| 197 try: | 189 try: |
| 198 co.apply_patch([patch.FilePatchDiff('chrome/file.cc', BAD_PATCH, [])]) | 190 co.apply_patch([patch.FilePatchDiff('chrome/file.cc', BAD_PATCH, [])]) |
| 199 self.fail() | 191 self.fail() |
| 200 except checkout.PatchApplicationFailed, e: | 192 except checkout.PatchApplicationFailed, e: |
| 201 self.assertEquals(e.filename, 'chrome/file.cc') | 193 self.assertEquals(e.filename, 'chrome/file.cc') |
| 202 self.assertEquals(e.status, err_msg) | 194 self.assertEquals(e.status, err_msg) |
| 203 | 195 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 data[name] = item.text | 270 data[name] = item.text |
| 279 set_item('author') | 271 set_item('author') |
| 280 set_item('msg') | 272 set_item('msg') |
| 281 revprops = logentry.find('revprops') | 273 revprops = logentry.find('revprops') |
| 282 if revprops != None: | 274 if revprops != None: |
| 283 data['revprops'] = [] | 275 data['revprops'] = [] |
| 284 for prop in revprops.getiterator('property'): | 276 for prop in revprops.getiterator('property'): |
| 285 data['revprops'].append((prop.attrib['name'], prop.text)) | 277 data['revprops'].append((prop.attrib['name'], prop.text)) |
| 286 return data | 278 return data |
| 287 | 279 |
| 280 def _check_base(self, co, root, expected): | |
| 281 read_only = isinstance(co, checkout.ReadOnlyCheckout) | |
| 282 self.assertEquals(not read_only, bool(expected)) | |
| 283 self.assertEquals(read_only, self.is_read_only) | |
| 284 if not read_only: | |
| 285 self.FAKE_REPOS.svn_dirty = True | |
| 286 | |
| 287 self.assertEquals(root, co.project_path) | |
| 288 self.assertEquals(self.previous_log['revision'], co.prepare(None)) | |
| 289 self.assertEquals('pouet', co.get_settings('bar')) | |
| 290 self.assertTree(self.get_trunk(False), root) | |
| 291 patches = self.get_patches() | |
| 292 co.apply_patch(patches) | |
| 293 self.assertEquals( | |
| 294 ['bin_file', 'chrome/file.cc', 'new_dir/subdir/new_file', 'extra'], | |
| 295 patches.filenames) | |
| 296 | |
| 297 # Verify that the patch is applied even for read only checkout. | |
| 298 self.assertTree(self.get_trunk(True), root) | |
| 299 fake_author = self.FAKE_REPOS.USERS[1][0] | |
| 300 revision = co.commit(u'msg', fake_author) | |
| 301 # Nothing changed. | |
| 302 self.assertTree(self.get_trunk(True), root) | |
| 303 | |
| 304 if read_only: | |
| 305 self.assertEquals('FAKE', revision) | |
| 306 self.assertEquals(self.previous_log['revision'], co.prepare(None)) | |
| 307 # Changes should be reverted now. | |
| 308 self.assertTree(self.get_trunk(False), root) | |
| 309 expected = self.previous_log | |
| 310 else: | |
| 311 self.assertEquals(self.previous_log['revision'] + 1, revision) | |
| 312 self.assertEquals(self.previous_log['revision'] + 1, co.prepare(None)) | |
| 313 self.assertTree(self.get_trunk(True), root) | |
| 314 expected = expected.copy() | |
| 315 expected['msg'] = 'msg' | |
| 316 expected['revision'] = self.previous_log['revision'] + 1 | |
| 317 expected.setdefault('author', fake_author) | |
| 318 | |
| 319 actual = self._log() | |
| 320 self.assertEquals(expected, actual) | |
| 321 | |
| 288 def _test_prepare(self, co): | 322 def _test_prepare(self, co): |
| 289 self.assertEquals(1, co.prepare(1)) | 323 self.assertEquals(1, co.prepare(1)) |
| 290 | 324 |
| 325 def get_trunk(self, modified): | |
| 326 tree = {} | |
| 327 subroot = 'trunk/' | |
| 328 for k, v in self.FAKE_REPOS.svn_revs[-1].iteritems(): | |
| 329 if k.startswith(subroot): | |
| 330 f = k[len(subroot):] | |
| 331 assert f not in tree | |
| 332 tree[f] = v | |
| 333 | |
| 334 if modified: | |
| 335 content_lines = tree['chrome/file.cc'].splitlines(True) | |
| 336 tree['chrome/file.cc'] = ''.join( | |
| 337 content_lines[0:5] + ['FOO!\n'] + content_lines[5:]) | |
| 338 del tree['extra'] | |
| 339 tree['new_dir/subdir/new_file'] = 'A new file\nshould exist.\n' | |
| 340 return tree | |
| 341 | |
| 342 | |
| 343 class GitBaseTest(BaseTest): | |
| 344 def setUp(self): | |
| 345 super(GitBaseTest, self).setUp() | |
| 346 self.enabled = self.FAKE_REPOS.set_up_git() | |
| 347 self.assertTrue(self.enabled) | |
| 348 self.previous_log = self._log() | |
| 349 | |
| 350 # pylint: disable=W0221 | |
| 351 def _log(self, log_from_local_repo=False): | |
| 352 if log_from_local_repo: | |
| 353 repo_root = os.path.join(self.root_dir, self.name) | |
| 354 else: | |
| 355 repo_root = os.path.join(self.FAKE_REPOS.git_root, | |
| 356 self.FAKE_REPOS.TEST_GIT_REPO) | |
| 357 out = subprocess2.check_output( | |
| 358 ['git', | |
| 359 '--git-dir', | |
| 360 os.path.join(repo_root, '.git'), | |
| 361 'log', '--pretty=format:"%H%x09%ae%x09%ad%x09%s"', | |
| 362 '--max-count=1']).strip('"') | |
| 363 if out and len(out.split()) != 0: | |
| 364 revision = out.split()[0] | |
| 365 else: | |
| 366 return {'revision': 0} | |
| 367 | |
| 368 return { | |
| 369 'revision': revision, | |
| 370 'author': out.split()[1], | |
| 371 'msg': out.split()[-1], | |
| 372 } | |
| 373 | |
| 374 def _check_base(self, co, root, expected): | |
| 375 read_only = isinstance(co, checkout.ReadOnlyCheckout) | |
| 376 self.assertEquals(read_only, self.is_read_only) | |
| 377 if not read_only: | |
| 378 self.FAKE_REPOS.git_dirty = True | |
| 379 | |
| 380 self.assertEquals(root, co.project_path) | |
| 381 self.assertEquals(self.previous_log['revision'], co.prepare(None)) | |
| 382 self.assertEquals('pouet', co.get_settings('bar')) | |
| 383 self.assertTree(self.get_trunk(False), root) | |
| 384 patches = self.get_patches() | |
| 385 co.apply_patch(patches) | |
| 386 self.assertEquals( | |
| 387 ['bin_file', 'chrome/file.cc', 'new_dir/subdir/new_file', 'extra'], | |
| 388 patches.filenames) | |
| 389 | |
| 390 # Hackish to verify _branches() internal function. | |
| 391 # pylint: disable=W0212 | |
| 392 self.assertEquals( | |
| 393 (['master', 'working_branch'], 'working_branch'), | |
| 394 co._branches()) | |
| 395 | |
| 396 # Verify that the patch is applied even for read only checkout. | |
| 397 self.assertTree(self.get_trunk(True), root) | |
| 398 fake_author = self.FAKE_REPOS.USERS[1][0] | |
| 399 revision = co.commit(u'msg', fake_author) | |
| 400 # Nothing changed. | |
| 401 self.assertTree(self.get_trunk(True), root) | |
| 402 | |
| 403 if read_only: | |
| 404 self.assertEquals('FAKE', revision) | |
| 405 self.assertEquals(self.previous_log['revision'], co.prepare(None)) | |
| 406 # Changes should be reverted now. | |
| 407 self.assertTree(self.get_trunk(False), root) | |
| 408 expected = self.previous_log | |
| 409 else: | |
| 410 self.assertEquals(self._log()['revision'], revision) | |
| 411 self.assertEquals(self._log()['revision'], co.prepare(None)) | |
| 412 self.assertTree(self.get_trunk(True), root) | |
| 413 expected = self._log() | |
| 414 | |
| 415 actual = self._log(log_from_local_repo=True) | |
| 416 self.assertEquals(expected, actual) | |
| 417 | |
| 418 def get_trunk(self, modified): | |
| 419 tree = {} | |
| 420 for k, v in self.FAKE_REPOS.git_hashes[ | |
| 421 self.FAKE_REPOS.TEST_GIT_REPO][1][1].iteritems(): | |
| 422 assert k not in tree | |
| 423 tree[k] = v | |
| 424 | |
| 425 if modified: | |
| 426 content_lines = tree['chrome/file.cc'].splitlines(True) | |
| 427 tree['chrome/file.cc'] = ''.join( | |
| 428 content_lines[0:5] + ['FOO!\n'] + content_lines[5:]) | |
| 429 tree['bin_file'] = '\x00' | |
| 430 del tree['extra'] | |
| 431 tree['new_dir/subdir/new_file'] = 'A new file\nshould exist.\n' | |
| 432 return tree | |
| 433 | |
| 434 def _test_prepare(self, co): | |
| 435 print co.prepare(None) | |
| 436 | |
| 437 | |
| 438 class GitCheckout(GitBaseTest): | |
| 439 def _get_co(self, post_processors): | |
| 440 self.assertNotEqual(False, post_processors) | |
| 441 return checkout.GitCheckout( | |
| 442 root_dir=self.root_dir, | |
| 443 project_name=self.name, | |
| 444 remote_branch='master', | |
| 445 git_url=os.path.join(self.FAKE_REPOS.git_root, | |
| 446 self.FAKE_REPOS.TEST_GIT_REPO), | |
| 447 commit_user=self.usr, | |
| 448 post_processors=post_processors) | |
| 449 | |
| 450 def testAll(self): | |
| 451 root = os.path.join(self.root_dir, self.name) | |
| 452 self._check_base(self._get_co(None), root, None) | |
| 453 | |
| 454 def testException(self): | |
| 455 self._check_exception( | |
| 456 self._get_co(None), | |
| 457 'While running git apply --index -p1;\n fatal: corrupt patch at line ' | |
| 458 '12\n') | |
| 459 | |
| 460 def testProcess(self): | |
| 461 self._test_process(self._get_co) | |
| 462 | |
| 463 def _testPrepare(self): | |
| 464 self._test_prepare(self._get_co(None)) | |
| 465 | |
| 466 def testMove(self): | |
| 467 co = self._get_co(None) | |
| 468 self._check_move(co) | |
| 469 out = subprocess2.check_output( | |
| 470 ['git', 'diff', 'HEAD~', '--name-status'], cwd=co.project_path) | |
| 471 out = sorted(out.splitlines()) | |
| 472 expected = sorted( | |
| 473 [ | |
| 474 'A\tchromeos/views/webui_menu_widget.h', | |
| 475 'D\tchromeos/views/DOMui_menu_widget.h', | |
| 476 ]) | |
| 477 self.assertEquals(expected, out) | |
| 478 | |
| 291 | 479 |
| 292 class SvnCheckout(SvnBaseTest): | 480 class SvnCheckout(SvnBaseTest): |
| 293 def _get_co(self, post_processors): | 481 def _get_co(self, post_processors): |
| 294 self.assertNotEqual(False, post_processors) | 482 self.assertNotEqual(False, post_processors) |
| 295 return checkout.SvnCheckout( | 483 return checkout.SvnCheckout( |
| 296 self.root_dir, self.name, self.usr, self.pwd, self.svn_url, | 484 self.root_dir, self.name, self.usr, self.pwd, self.svn_url, |
| 297 post_processors) | 485 post_processors) |
| 298 | 486 |
| 299 def testAll(self): | 487 def testAll(self): |
| 300 expected = { | 488 expected = { |
| 301 'author': self.FAKE_REPOS.USERS[0][0], | 489 'author': self.FAKE_REPOS.USERS[0][0], |
| 302 'revprops': [('realauthor', self.FAKE_REPOS.USERS[1][0])] | 490 'revprops': [('realauthor', self.FAKE_REPOS.USERS[1][0])] |
| 303 } | 491 } |
| 304 root = os.path.join(self.root_dir, self.name) | 492 root = os.path.join(self.root_dir, self.name) |
| 305 self._check_base(self._get_co(None), root, False, expected) | 493 self._check_base(self._get_co(None), root, expected) |
| 306 | 494 |
| 307 def testException(self): | 495 def testException(self): |
| 308 self._check_exception( | 496 self._check_exception( |
| 309 self._get_co(None), | 497 self._get_co(None), |
| 310 'While running patch -p1 --forward --force --no-backup-if-mismatch;\n' | 498 'While running patch -p1 --forward --force --no-backup-if-mismatch;\n' |
| 311 ' patching file chrome/file.cc\n' | 499 ' patching file chrome/file.cc\n' |
| 312 ' Hunk #1 FAILED at 3.\n' | 500 ' Hunk #1 FAILED at 3.\n' |
| 313 ' 1 out of 1 hunk FAILED -- saving rejects to file ' | 501 ' 1 out of 1 hunk FAILED -- saving rejects to file ' |
| 314 'chrome/file.cc.rej\n') | 502 'chrome/file.cc.rej\n') |
| 315 | 503 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 | 538 |
| 351 def testWithRevPropsSupport(self): | 539 def testWithRevPropsSupport(self): |
| 352 # Add the hook that will commit in a way that removes the race condition. | 540 # Add the hook that will commit in a way that removes the race condition. |
| 353 hook = os.path.join(self.FAKE_REPOS.svn_repo, 'hooks', 'pre-commit') | 541 hook = os.path.join(self.FAKE_REPOS.svn_repo, 'hooks', 'pre-commit') |
| 354 shutil.copyfile(os.path.join(ROOT_DIR, 'sample_pre_commit_hook'), hook) | 542 shutil.copyfile(os.path.join(ROOT_DIR, 'sample_pre_commit_hook'), hook) |
| 355 os.chmod(hook, 0755) | 543 os.chmod(hook, 0755) |
| 356 expected = { | 544 expected = { |
| 357 'revprops': [('commit-bot', 'user1@example.com')], | 545 'revprops': [('commit-bot', 'user1@example.com')], |
| 358 } | 546 } |
| 359 root = os.path.join(self.root_dir, self.name) | 547 root = os.path.join(self.root_dir, self.name) |
| 360 self._check_base(self._get_co(None), root, False, expected) | 548 self._check_base(self._get_co(None), root, expected) |
| 361 | 549 |
| 362 def testWithRevPropsSupportNotCommitBot(self): | 550 def testWithRevPropsSupportNotCommitBot(self): |
| 363 # Add the hook that will commit in a way that removes the race condition. | 551 # Add the hook that will commit in a way that removes the race condition. |
| 364 hook = os.path.join(self.FAKE_REPOS.svn_repo, 'hooks', 'pre-commit') | 552 hook = os.path.join(self.FAKE_REPOS.svn_repo, 'hooks', 'pre-commit') |
| 365 shutil.copyfile(os.path.join(ROOT_DIR, 'sample_pre_commit_hook'), hook) | 553 shutil.copyfile(os.path.join(ROOT_DIR, 'sample_pre_commit_hook'), hook) |
| 366 os.chmod(hook, 0755) | 554 os.chmod(hook, 0755) |
| 367 co = checkout.SvnCheckout( | 555 co = checkout.SvnCheckout( |
| 368 self.root_dir, self.name, | 556 self.root_dir, self.name, |
| 369 self.FAKE_REPOS.USERS[1][0], self.FAKE_REPOS.USERS[1][1], | 557 self.FAKE_REPOS.USERS[1][0], self.FAKE_REPOS.USERS[1][1], |
| 370 self.svn_url) | 558 self.svn_url) |
| 371 root = os.path.join(self.root_dir, self.name) | 559 root = os.path.join(self.root_dir, self.name) |
| 372 expected = { | 560 expected = { |
| 373 'author': self.FAKE_REPOS.USERS[1][0], | 561 'author': self.FAKE_REPOS.USERS[1][0], |
| 374 } | 562 } |
| 375 self._check_base(co, root, False, expected) | 563 self._check_base(co, root, expected) |
| 376 | 564 |
| 377 def testAutoProps(self): | 565 def testAutoProps(self): |
| 378 co = self._get_co(None) | 566 co = self._get_co(None) |
| 379 co.svn_config = checkout.SvnConfig( | 567 co.svn_config = checkout.SvnConfig( |
| 380 os.path.join(ROOT_DIR, 'subversion_config')) | 568 os.path.join(ROOT_DIR, 'subversion_config')) |
| 381 co.prepare(None) | 569 co.prepare(None) |
| 382 patches = self.get_patches() | 570 patches = self.get_patches() |
| 383 co.apply_patch(patches) | 571 co.apply_patch(patches) |
| 384 self.assertEquals( | 572 self.assertEquals( |
| 385 ['bin_file', 'chrome/file.cc', 'new_dir/subdir/new_file', 'extra'], | 573 ['bin_file', 'chrome/file.cc', 'new_dir/subdir/new_file', 'extra'], |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 | 693 |
| 506 def _get_co(self, post_processors): | 694 def _get_co(self, post_processors): |
| 507 self.assertNotEqual(False, post_processors) | 695 self.assertNotEqual(False, post_processors) |
| 508 return checkout.ReadOnlyCheckout( | 696 return checkout.ReadOnlyCheckout( |
| 509 checkout.SvnCheckout( | 697 checkout.SvnCheckout( |
| 510 self.root_dir, self.name, None, None, self.svn_url, None), | 698 self.root_dir, self.name, None, None, self.svn_url, None), |
| 511 post_processors) | 699 post_processors) |
| 512 | 700 |
| 513 def testAll(self): | 701 def testAll(self): |
| 514 root = os.path.join(self.root_dir, self.name) | 702 root = os.path.join(self.root_dir, self.name) |
| 515 self._check_base(self._get_co(None), root, False, None) | 703 self._check_base(self._get_co(None), root, None) |
| 516 | 704 |
| 517 def testException(self): | 705 def testException(self): |
| 518 self._check_exception( | 706 self._check_exception( |
| 519 self._get_co(None), | 707 self._get_co(None), |
| 520 'While running patch -p1 --forward --force --no-backup-if-mismatch;\n' | 708 'While running patch -p1 --forward --force --no-backup-if-mismatch;\n' |
| 521 ' patching file chrome/file.cc\n' | 709 ' patching file chrome/file.cc\n' |
| 522 ' Hunk #1 FAILED at 3.\n' | 710 ' Hunk #1 FAILED at 3.\n' |
| 523 ' 1 out of 1 hunk FAILED -- saving rejects to file ' | 711 ' 1 out of 1 hunk FAILED -- saving rejects to file ' |
| 524 'chrome/file.cc.rej\n') | 712 'chrome/file.cc.rej\n') |
| 525 | 713 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 537 if '-v' in sys.argv: | 725 if '-v' in sys.argv: |
| 538 DEBUGGING = True | 726 DEBUGGING = True |
| 539 logging.basicConfig( | 727 logging.basicConfig( |
| 540 level=logging.DEBUG, | 728 level=logging.DEBUG, |
| 541 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') | 729 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') |
| 542 else: | 730 else: |
| 543 logging.basicConfig( | 731 logging.basicConfig( |
| 544 level=logging.ERROR, | 732 level=logging.ERROR, |
| 545 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') | 733 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') |
| 546 unittest.main() | 734 unittest.main() |
| OLD | NEW |