Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: tests/git_common_test.py

Issue 311243003: Make git-freeze bail out if the user has too much untracked data. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Unnecessary genexp Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« git_common.py ('K') | « man/src/git-freeze.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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_common.py""" 6 """Unit tests for git_common.py"""
7 7
8 import binascii 8 import binascii
9 import collections 9 import collections
10 import os 10 import os
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 self.repo.git('rebase', '--continue') 570 self.repo.git('rebase', '--continue')
571 571
572 self.assertSchema(""" 572 self.assertSchema("""
573 A B C D E F G H I J K L 573 A B C D E F G H I J K L
574 574
575 X Y Z 575 X Y Z
576 576
577 CAT DOG 577 CAT DOG
578 """) 578 """)
579 579
580 def testStatus(self):
581 def inner():
582 dictified_status = lambda: {
583 k: dict(v._asdict()) # pylint: disable=W0212
584 for k, v in self.repo.run(self.gc.status).iteritems()
585 }
586 self.repo.git('mv', 'file', 'cat')
587 with open('COOL', 'w') as f:
588 f.write('Super cool file!')
589 self.assertDictEqual(
590 dictified_status(),
591 {'cat': {'lstat': 'R', 'rstat': ' ', 'src': 'file'},
592 'COOL': {'lstat': '?', 'rstat': '?', 'src': 'COOL'}}
593 )
594
595 self.repo.run(inner)
596
580 597
581 class GitFreezeThaw(git_test_utils.GitRepoReadWriteTestBase): 598 class GitFreezeThaw(git_test_utils.GitRepoReadWriteTestBase):
582 @classmethod 599 @classmethod
583 def setUpClass(cls): 600 def setUpClass(cls):
584 super(GitFreezeThaw, cls).setUpClass() 601 super(GitFreezeThaw, cls).setUpClass()
585 import git_common 602 import git_common
586 cls.gc = git_common 603 cls.gc = git_common
587 cls.gc.TEST_MODE = True 604 cls.gc.TEST_MODE = True
588 605
589 REPO_SCHEMA = """ 606 REPO_SCHEMA = """
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 self.assertEquals(self.repo.git('status', '--porcelain').stdout, '') 665 self.assertEquals(self.repo.git('status', '--porcelain').stdout, '')
649 666
650 # Thaw it out! 667 # Thaw it out!
651 self.assertIsNone(self.gc.thaw()) 668 self.assertIsNone(self.gc.thaw())
652 self.assertIsNotNone(self.gc.thaw()) # One thaw should thaw everything 669 self.assertIsNotNone(self.gc.thaw()) # One thaw should thaw everything
653 670
654 self.assertEquals(self.repo.git('status', '--porcelain').stdout, STATUS_1) 671 self.assertEquals(self.repo.git('status', '--porcelain').stdout, STATUS_1)
655 672
656 self.repo.run(inner) 673 self.repo.run(inner)
657 674
675 def testTooBig(self):
676 def inner():
677 self.repo.git('config', 'depot-tools.freeze-size-limit', '1')
678 with open('bigfile', 'w') as f:
679 chunk = 'NERDFACE' * 1024
680 for _ in xrange(128 * 2 + 1): # Just over 2 mb
681 f.write(chunk)
682 _, err = self.repo.capture_stdio(self.gc.freeze)
683 self.assertIn('too much untracked+unignored', err)
684
685 self.repo.run(inner)
686
658 687
659 if __name__ == '__main__': 688 if __name__ == '__main__':
660 sys.exit(coverage_utils.covered_main( 689 sys.exit(coverage_utils.covered_main(
661 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py') 690 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py')
662 )) 691 ))
OLDNEW
« git_common.py ('K') | « man/src/git-freeze.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698