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_common_test.py

Issue 181043018: Add git thaw/freeze to depot_tools. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@git_map
Patch Set: fix space 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 | « git_freezer.py ('k') | tests/git_freezer_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
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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 121
122 def flush(self): 122 def flush(self):
123 self.count += 1 123 self.count += 1
124 124
125 @unittest.expectedFailure 125 @unittest.expectedFailure
126 def testBasic(self): 126 def testBasic(self):
127 """This test is probably racy, but I don't have a better alternative.""" 127 """This test is probably racy, but I don't have a better alternative."""
128 fmt = '%(count)d/10' 128 fmt = '%(count)d/10'
129 stream = self.FakeStream() 129 stream = self.FakeStream()
130 130
131 pp = self.gc.ProgressPrinter(fmt, enabled=True, stream=stream, period=0.01) 131 pp = self.gc.ProgressPrinter(fmt, enabled=True, fout=stream, period=0.01)
132 with pp as inc: 132 with pp as inc:
133 for _ in xrange(10): 133 for _ in xrange(10):
134 time.sleep(0.02) 134 time.sleep(0.02)
135 inc() 135 inc()
136 136
137 filtered = set(x.strip() for x in stream.data) 137 filtered = set(x.strip() for x in stream.data)
138 rslt = set(fmt % {'count': i} for i in xrange(11)) 138 rslt = set(fmt % {'count': i} for i in xrange(11))
139 self.assertSetEqual(filtered, rslt) 139 self.assertSetEqual(filtered, rslt)
140 self.assertGreaterEqual(stream.count, 10) 140 self.assertGreaterEqual(stream.count, 10)
141 141
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 self.repo['A'], 183 self.repo['A'],
184 self.repo['B'], 184 self.repo['B'],
185 self.repo['E'], 185 self.repo['E'],
186 self.repo['C'], 186 self.repo['C'],
187 ], ret) 187 ], ret)
188 self.assertEquals( 188 self.assertEquals(
189 self.repo.run(self.gc.hash_one, 'branch_D'), 189 self.repo.run(self.gc.hash_one, 'branch_D'),
190 self.repo['D'] 190 self.repo['D']
191 ) 191 )
192 192
193 def testStream(self):
194 items = set(self.repo.commit_map.itervalues())
195
196 def testfn():
197 for line in self.gc.stream('log', '--format=%H').xreadlines():
198 line = line.strip()
199 self.assertIn(line, items)
200 items.remove(line)
201
202 self.repo.run(testfn)
203
193 def testCurrentBranch(self): 204 def testCurrentBranch(self):
194 self.repo.git('checkout', 'branch_D') 205 self.repo.git('checkout', 'branch_D')
195 self.assertEqual(self.repo.run(self.gc.current_branch), 'branch_D') 206 self.assertEqual(self.repo.run(self.gc.current_branch), 'branch_D')
196 207
197 def testBranches(self): 208 def testBranches(self):
198 self.assertEqual(self.repo.run(set, self.gc.branches()), 209 self.assertEqual(self.repo.run(set, self.gc.branches()),
199 set(('branch_D', 'root_A'))) 210 set(('branch_D', 'root_A')))
200 211
201 def testTags(self): 212 def testTags(self):
202 self.assertEqual(set(self.repo.run(self.gc.tags)), 213 self.assertEqual(set(self.repo.run(self.gc.tags)),
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 self.assertEquals(self.repo.run(self.gc.upstream, 'master'), None) 317 self.assertEquals(self.repo.run(self.gc.upstream, 'master'), None)
307 self.repo.git('checkout', '-tb', 'happybranch', 'master') 318 self.repo.git('checkout', '-tb', 'happybranch', 'master')
308 self.assertEquals(self.repo.run(self.gc.upstream, 'happybranch'), 319 self.assertEquals(self.repo.run(self.gc.upstream, 'happybranch'),
309 'master') 320 'master')
310 321
311 322
312 if __name__ == '__main__': 323 if __name__ == '__main__':
313 sys.exit(coverage_utils.covered_main( 324 sys.exit(coverage_utils.covered_main(
314 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py') 325 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py')
315 )) 326 ))
OLDNEW
« no previous file with comments | « git_freezer.py ('k') | tests/git_freezer_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698