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

Side by Side Diff: tests/gclient_scm_test.py

Issue 250523004: Added remote 'git' branch awareness to 'gclient' (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
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 gclient_scm.py.""" 6 """Unit tests for gclient_scm.py."""
7 7
8 # pylint: disable=E1103 8 # pylint: disable=E1103
9 9
10 # Import before super_mox to keep valid references. 10 # Import before super_mox to keep valid references.
(...skipping 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 relpath=self.relpath) 1369 relpath=self.relpath)
1370 file_list = [] 1370 file_list = []
1371 options.revision = 'unmanaged' 1371 options.revision = 'unmanaged'
1372 scm.update(options, (), file_list) 1372 scm.update(options, (), file_list)
1373 self.assertEquals(file_list, expected_file_list) 1373 self.assertEquals(file_list, expected_file_list)
1374 self.assertEquals(scm.revinfo(options, (), None), 1374 self.assertEquals(scm.revinfo(options, (), None),
1375 '069c602044c5388d2d15c3f875b057c852003458') 1375 '069c602044c5388d2d15c3f875b057c852003458')
1376 self.checkstdout('________ unmanaged solution; skipping .\n') 1376 self.checkstdout('________ unmanaged solution; skipping .\n')
1377 1377
1378 1378
1379 class GitParseRevisionTestCase(unittest.TestCase):
1380 """Tests the 'GitWrapper._ResolveLocalRef' function."""
1381
1382 def setUp(self):
1383 self.repo = gclient_scm.GitWrapper('fake/fake.git')
1384
1385 def _assertMapped(self, revision):
1386 self.assertTrue(self.repo._ParseRevision(revision)['mapped'])
1387 def _assertNotMapped(self, revision):
1388 self.assertFalse(self.repo._ParseRevision(revision)['mapped'])
1389
1390 def testLocalRefs(self):
1391 self._assertMapped('refs/heads/master')
1392 self._assertMapped('refs/heads/some_branch')
1393 self._assertMapped('origin/master')
1394 self._assertMapped('refs/remotes/origin/master')
1395
1396 def testRemoteRefs(self):
1397 self._assertNotMapped('refs/remotes/other/master')
1398 self._assertNotMapped('refs/other')
1399
1400 def testNonRefs(self):
1401 self._assertMapped('1d229271928d3f9e2bb0375bd6ce5db6c6d348d9')
1402 self._assertMapped('1d2292')
1403 self._assertMapped('my_branch')
1404
1405 def testFetchRefspec(self):
1406 def r(revision):
1407 return self.repo._ParseRevision(revision)['fetch_refspec']
1408
1409 self.assertEquals(r('master'), 'master')
1410 self.assertEquals(r('refs/heads/master'), 'master')
1411 self.assertEquals(r('refs/remotes/origin/master'), 'master')
1412 self.assertEquals(r('refs/other'), 'refs/other:refs/other')
1413 self.assertEquals(
1414 r('refs/remotes/other/master'),
1415 'refs/remotes/other/master:refs/remotes/other/master')
1416 self.assertEquals(
1417 r('refs/for/master'),
1418 'refs/for/master:refs/for/master')
1419
1420 def testType(self):
1421 def assertBranch(rev):
1422 self.assertEquals(self.repo._ParseRevision(rev)['type'], 'branch')
1423 def assertHash(rev):
1424 self.assertEquals(self.repo._ParseRevision(rev)['type'], 'hash')
1425
1426 assertBranch('refs/heads/master')
1427 assertBranch('refs/remotes/origin/master')
1428 assertBranch('origin/master')
1429 assertBranch('refs/heads/some_branch')
1430 assertBranch('refs/remotes/origin/some_branch')
1431 assertBranch('origin/some_branch')
1432
1433 assertHash('1d229271928d3f9e2bb0375bd6ce5db6c6d348d9')
1434 assertHash('1d22927')
1435
1436 def testRevisionLocalization(self):
1437 def r(revision):
1438 return self.repo._ParseRevision(revision)['revision']
1439
1440 self.assertEquals(r('refs/heads/master'), 'refs/heads/master')
1441 self.assertEquals(
1442 r('refs/remotes/origin/master'),
1443 'refs/remotes/origin/master')
1444 self.assertEquals(r('origin/master'), 'refs/heads/master')
1445 self.assertEquals(r('origin/other'), 'refs/heads/other')
1446
1447 self.assertEquals(
1448 r('1d229271928d3f9e2bb0375bd6ce5db6c6d348d9'),
1449 '1d229271928d3f9e2bb0375bd6ce5db6c6d348d9')
1450 self.assertEquals(r('1d22927'), '1d22927')
1451
1452
1379 if __name__ == '__main__': 1453 if __name__ == '__main__':
1380 if '-v' in sys.argv: 1454 if '-v' in sys.argv:
1381 logging.basicConfig( 1455 logging.basicConfig(
1382 level=logging.DEBUG, 1456 level=logging.DEBUG,
1383 format='%(asctime).19s %(levelname)s %(filename)s:' 1457 format='%(asctime).19s %(levelname)s %(filename)s:'
1384 '%(lineno)s %(message)s') 1458 '%(lineno)s %(message)s')
1385 unittest.main() 1459 unittest.main()
1386 1460
1387 # vim: ts=2:sw=2:tw=80:et: 1461 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« gclient_scm.py ('K') | « testing_support/fake_repos.py ('k') | tests/gclient_smoketest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698