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

Side by Side Diff: tests/git_common_test.py

Issue 184113002: Add git-map and git-short-map to depot_tools. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@new_branch
Patch Set: Make it work on windows 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 | « testing_support/git_test_utils.py ('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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 COMMIT_E = { 163 COMMIT_E = {
164 'some/files/file2': {'data': 'file2 - merged'}, 164 'some/files/file2': {'data': 'file2 - merged'},
165 } 165 }
166 166
167 COMMIT_D = { 167 COMMIT_D = {
168 'some/files/file2': {'data': 'file2 - vanilla\nfile2 - merged'}, 168 'some/files/file2': {'data': 'file2 - vanilla\nfile2 - merged'},
169 } 169 }
170 170
171 def testHashes(self): 171 def testHashes(self):
172 ret = self.repo.run( 172 ret = self.repo.run(
173 self.gc.hashes, *[ 173 self.gc.hash_multi, *[
174 'master', 174 'master',
175 'master~3', 175 'master~3',
176 self.repo['E']+'~', 176 self.repo['E']+'~',
177 self.repo['D']+'^2', 177 self.repo['D']+'^2',
178 'tag_C^{}', 178 'tag_C^{}',
179 ] 179 ]
180 ) 180 )
181 self.assertEqual([ 181 self.assertEqual([
182 self.repo['D'], 182 self.repo['D'],
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(
189 self.repo.run(self.gc.hash_one, 'branch_D'),
190 self.repo['D']
191 )
192
193 def testCurrentBranch(self):
194 self.repo.git('checkout', 'branch_D')
195 self.assertEqual(self.repo.run(self.gc.current_branch), 'branch_D')
196
197 def testBranches(self):
198 self.assertEqual(self.repo.run(set, self.gc.branches()),
199 set(('branch_D', 'root_A')))
200
201 def testTags(self):
202 self.assertEqual(set(self.repo.run(self.gc.tags)),
203 {'tag_'+l for l in 'ABCDE'})
188 204
189 def testParseCommitrefs(self): 205 def testParseCommitrefs(self):
190 ret = self.repo.run( 206 ret = self.repo.run(
191 self.gc.parse_commitrefs, *[ 207 self.gc.parse_commitrefs, *[
192 'master', 208 'master',
193 'master~3', 209 'master~3',
194 self.repo['E']+'~', 210 self.repo['E']+'~',
195 self.repo['D']+'^2', 211 self.repo['D']+'^2',
196 'tag_C^{}', 212 'tag_C^{}',
197 ] 213 ]
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 self.assertEquals(data, self.repo.git('cat-file', 'blob', data_hash).stdout) 283 self.assertEquals(data, self.repo.git('cat-file', 'blob', data_hash).stdout)
268 284
269 def testMkTree(self): 285 def testMkTree(self):
270 tree = {} 286 tree = {}
271 for i in 1, 2, 3: 287 for i in 1, 2, 3:
272 name = 'file%d' % i 288 name = 'file%d' % i
273 tree[name] = ('100644', 'blob', self._intern_data(name)) 289 tree[name] = ('100644', 'blob', self._intern_data(name))
274 tree_hash = self.repo.run(self.gc.mktree, tree) 290 tree_hash = self.repo.run(self.gc.mktree, tree)
275 self.assertEquals('37b61866d6e061c4ba478e7eb525be7b5752737d', tree_hash) 291 self.assertEquals('37b61866d6e061c4ba478e7eb525be7b5752737d', tree_hash)
276 292
293 def testConfig(self):
294 self.repo.git('config', '--add', 'happy.derpies', 'food')
295 self.assertEquals(self.repo.run(self.gc.config_list, 'happy.derpies'),
296 ['food'])
297 self.assertEquals(self.repo.run(self.gc.config_list, 'sad.derpies'), [])
298
299 self.repo.git('config', '--add', 'happy.derpies', 'cat')
300 self.assertEquals(self.repo.run(self.gc.config_list, 'happy.derpies'),
301 ['food', 'cat'])
302
303 def testUpstream(self):
304 self.repo.git('commit', '--allow-empty', '-am', 'foooooo')
305 self.assertEquals(self.repo.run(self.gc.upstream, 'bobly'), None)
306 self.assertEquals(self.repo.run(self.gc.upstream, 'master'), None)
307 self.repo.git('checkout', '-tb', 'happybranch', 'master')
308 self.assertEquals(self.repo.run(self.gc.upstream, 'happybranch'),
309 'master')
310
277 311
278 if __name__ == '__main__': 312 if __name__ == '__main__':
279 sys.exit(coverage_utils.covered_main( 313 sys.exit(coverage_utils.covered_main(
280 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py') 314 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py')
281 )) 315 ))
OLDNEW
« no previous file with comments | « testing_support/git_test_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698