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

Side by Side Diff: tests/git_freezer_test.py

Issue 184253003: Add git-reup and friends (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@freeze_thaw
Patch Set: fix pylint Created 6 years, 9 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
« no previous file with comments | « tests/git_common_test.py ('k') | tests/git_number_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Unit tests for git_freezer.py"""
7
8 import os
9 import sys
10
11 DEPOT_TOOLS_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
12 sys.path.insert(0, DEPOT_TOOLS_ROOT)
13
14 from testing_support import coverage_utils
15 from testing_support import git_test_utils
16
17
18 class GitFreezeThaw(git_test_utils.GitRepoReadWriteTestBase):
19 @classmethod
20 def setUpClass(cls):
21 super(GitFreezeThaw, cls).setUpClass()
22 import git_freezer
23 cls.gf = git_freezer
24
25 REPO = """
26 A B C D
27 B E D
28 """
29
30 COMMIT_A = {
31 'some/files/file1': {'data': 'file1'},
32 'some/files/file2': {'data': 'file2'},
33 'some/files/file3': {'data': 'file3'},
34 'some/other/file': {'data': 'otherfile'},
35 }
36
37 COMMIT_C = {
38 'some/files/file2': {
39 'mode': 0755,
40 'data': 'file2 - vanilla'},
41 }
42
43 COMMIT_E = {
44 'some/files/file2': {'data': 'file2 - merged'},
45 }
46
47 COMMIT_D = {
48 'some/files/file2': {'data': 'file2 - vanilla\nfile2 - merged'},
49 }
50
51 def testNothing(self):
52 self.assertIsNotNone(self.repo.run(self.gf.thaw)) # 'Nothing to thaw'
53 self.assertIsNotNone(self.repo.run(self.gf.freeze)) # 'Nothing to freeze'
54
55 def testAll(self):
56 def inner():
57 with open('some/files/file2', 'a') as f2:
58 print >> f2, 'cool appended line'
59 os.mkdir('some/other_files')
60 with open('some/other_files/subdir_file', 'w') as f3:
61 print >> f3, 'new file!'
62 with open('some/files/file5', 'w') as f5:
63 print >> f5, 'New file!1!one!'
64
65 STATUS_1 = '\n'.join((
66 ' M some/files/file2',
67 'A some/files/file5',
68 '?? some/other_files/'
69 )) + '\n'
70
71 self.repo.git('add', 'some/files/file5')
72
73 # Freeze group 1
74 self.assertEquals(self.repo.git('status', '--porcelain').stdout, STATUS_1)
75 self.assertIsNone(self.gf.freeze())
76 self.assertEquals(self.repo.git('status', '--porcelain').stdout, '')
77
78 # Freeze group 2
79 with open('some/files/file2', 'a') as f2:
80 print >> f2, 'new! appended line!'
81 self.assertEquals(self.repo.git('status', '--porcelain').stdout,
82 ' M some/files/file2\n')
83 self.assertIsNone(self.gf.freeze())
84 self.assertEquals(self.repo.git('status', '--porcelain').stdout, '')
85
86 # Thaw it out!
87 self.assertIsNone(self.gf.thaw())
88 self.assertIsNotNone(self.gf.thaw()) # One thaw should thaw everything
89
90 self.assertEquals(self.repo.git('status', '--porcelain').stdout, STATUS_1)
91
92 self.repo.run(inner)
93
94
95
96 if __name__ == '__main__':
97 sys.exit(coverage_utils.covered_main(
98 os.path.join(DEPOT_TOOLS_ROOT, 'git_freezer.py')
99 ))
OLDNEW
« no previous file with comments | « tests/git_common_test.py ('k') | tests/git_number_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698