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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 expected = self._log() | 416 expected = self._log() |
417 | 417 |
418 actual = self._log(log_from_local_repo=True) | 418 actual = self._log(log_from_local_repo=True) |
419 self.assertEquals(expected, actual) | 419 self.assertEquals(expected, actual) |
420 | 420 |
421 def get_trunk(self, modified): | 421 def get_trunk(self, modified): |
422 tree = {} | 422 tree = {} |
423 for k, v in self.FAKE_REPOS.git_hashes[ | 423 for k, v in self.FAKE_REPOS.git_hashes[ |
424 self.FAKE_REPOS.TEST_GIT_REPO][1][1].iteritems(): | 424 self.FAKE_REPOS.TEST_GIT_REPO][1][1].iteritems(): |
425 assert k not in tree | 425 assert k not in tree |
426 tree[k] = v | 426 tree[k] = v |
427 | 427 |
428 if modified: | 428 if modified: |
429 content_lines = tree['chrome/file.cc'].splitlines(True) | 429 content_lines = tree['chrome/file.cc'].splitlines(True) |
430 tree['chrome/file.cc'] = ''.join( | 430 tree['chrome/file.cc'] = ''.join( |
431 content_lines[0:5] + ['FOO!\n'] + content_lines[5:]) | 431 content_lines[0:5] + ['FOO!\n'] + content_lines[5:]) |
432 tree['bin_file'] = '\x00' | 432 tree['bin_file'] = '\x00' |
433 del tree['extra'] | 433 del tree['extra'] |
434 tree['new_dir/subdir/new_file'] = 'A new file\nshould exist.\n' | 434 tree['new_dir/subdir/new_file'] = 'A new file\nshould exist.\n' |
435 return tree | 435 return tree |
436 | 436 |
(...skipping 26 matching lines...) Expand all Loading... |
463 def testProcess(self): | 463 def testProcess(self): |
464 self._test_process(self._get_co) | 464 self._test_process(self._get_co) |
465 | 465 |
466 def _testPrepare(self): | 466 def _testPrepare(self): |
467 self._test_prepare(self._get_co(None)) | 467 self._test_prepare(self._get_co(None)) |
468 | 468 |
469 def testMove(self): | 469 def testMove(self): |
470 co = self._get_co(None) | 470 co = self._get_co(None) |
471 self._check_move(co) | 471 self._check_move(co) |
472 out = subprocess2.check_output( | 472 out = subprocess2.check_output( |
473 ['git', 'diff', '--staged', '--name-status'], cwd=co.project_path) | 473 ['git', 'diff', 'HEAD~', '--name-status'], cwd=co.project_path) |
474 out = sorted(out.splitlines()) | 474 out = sorted(out.splitlines()) |
475 expected = sorted( | 475 expected = sorted( |
476 [ | 476 [ |
477 'A\tchromeos/views/webui_menu_widget.h', | 477 'A\tchromeos/views/webui_menu_widget.h', |
478 'D\tchromeos/views/DOMui_menu_widget.h', | 478 'D\tchromeos/views/DOMui_menu_widget.h', |
479 ]) | 479 ]) |
480 self.assertEquals(expected, out) | 480 self.assertEquals(expected, out) |
481 | 481 |
482 | 482 |
483 class SvnCheckout(SvnBaseTest): | 483 class SvnCheckout(SvnBaseTest): |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 if '-v' in sys.argv: | 728 if '-v' in sys.argv: |
729 DEBUGGING = True | 729 DEBUGGING = True |
730 logging.basicConfig( | 730 logging.basicConfig( |
731 level=logging.DEBUG, | 731 level=logging.DEBUG, |
732 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') | 732 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') |
733 else: | 733 else: |
734 logging.basicConfig( | 734 logging.basicConfig( |
735 level=logging.ERROR, | 735 level=logging.ERROR, |
736 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') | 736 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') |
737 unittest.main() | 737 unittest.main() |
OLD | NEW |