Index: tests/gclient_scm_test.py |
diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py |
index e33ee0232fa4198f4513f4fb5b598abab6b21c17..17b56240a11583250254ffd1215a752fbd938435 100755 |
--- a/tests/gclient_scm_test.py |
+++ b/tests/gclient_scm_test.py |
@@ -1278,7 +1278,6 @@ class ManagedGitWrapperTestCaseMox(BaseTestCase): |
cwd=self.base_path).AndRaise(error) |
gclient_scm.GitWrapper._Fetch(options) |
gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path) |
- gclient_scm.GitWrapper._Fetch(options) |
self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) |
gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes( |
@@ -1289,6 +1288,8 @@ class ManagedGitWrapperTestCaseMox(BaseTestCase): |
).AndReturn(True) |
gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=too_big |
).MultipleTimes(2).AndReturn(False) |
+ # pylint: disable=E1120 |
+ gclient_scm.GitWrapper._Fetch(options) |
gclient_scm.os.path.isdir(self.base_path).AndReturn(False) |
gclient_scm.os.path.isdir(self.base_path).MultipleTimes().AndReturn(True) |
@@ -1580,6 +1581,99 @@ class UnmanagedGitWrapperTestCase(BaseGitWrapperTestCase): |
self.checkstdout('________ unmanaged solution; skipping .\n') |
+class GitRefishTestCase(unittest.TestCase): |
+ |
+ @staticmethod |
+ def parse(revision, **kwargs): |
+ kwargs.setdefault('remote', 'origin') |
+ kwargs.setdefault('other_remotes', ('server', 'backup')) |
+ return gclient_scm.GitRefish.Parse(revision, **kwargs) |
+ |
+ def testParse(self): |
+ self.assertEquals( |
M-A Ruel
2014/06/25 01:24:58
assertEqual. Likely loop based.
dnj
2014/06/25 20:14:02
Done.
|
+ self.parse('refs/heads/master'), |
+ gclient_scm.GitRefish( |
+ source='refs/heads/master', |
+ is_branch=True, |
+ local_ref='master', |
+ remote='origin', |
+ remote_ref='master', |
+ remote_refspec='origin/master', |
+ upstream_branch='refs/remotes/origin/master', |
+ ) |
+ ) |
+ |
+ self.assertEquals( |
+ self.parse('origin/foo/bar'), |
+ gclient_scm.GitRefish( |
+ source='origin/foo/bar', |
+ is_branch=True, |
+ local_ref='refs/remotes/origin/foo/bar', |
+ remote='origin', |
+ remote_ref='foo/bar', |
+ remote_refspec='origin/foo/bar', |
+ upstream_branch='origin/foo/bar', |
+ ) |
+ ) |
+ |
+ self.assertEquals( |
+ self.parse('server/foo/bar'), |
+ gclient_scm.GitRefish( |
+ source='server/foo/bar', |
+ is_branch=True, |
+ local_ref='refs/remotes/server/foo/bar', |
+ remote='server', |
+ remote_ref='foo/bar', |
+ remote_refspec='server/foo/bar', |
+ upstream_branch='server/foo/bar', |
+ ) |
+ ) |
+ |
+ self.assertEquals( |
+ self.parse('refs/remotes/foo/bar/baz'), |
+ gclient_scm.GitRefish( |
+ source='refs/remotes/foo/bar/baz', |
+ is_branch=True, |
+ local_ref='refs/remotes/foo/bar/baz', |
+ remote='foo', |
+ remote_ref='bar/baz', |
+ remote_refspec='foo/bar/baz', |
+ upstream_branch='refs/remotes/foo/bar/baz', |
+ ) |
+ ) |
+ |
+ hash_value = '0c745b5ff533cf50a8731e168908644a9d9be4cf' |
+ self.assertEquals( |
+ self.parse(hash_value), |
+ gclient_scm.GitRefish( |
+ source=hash_value, |
+ is_branch=False, |
+ local_ref=hash_value, |
+ remote='origin', |
+ remote_ref=hash_value, |
+ remote_refspec=hash_value, |
+ upstream_branch=None, |
+ ) |
+ ) |
+ |
+ # Short hash (consider it a hash) |
+ hash_value = '0c745b5' |
+ self.assertEquals( |
+ self.parse( |
+ hash_value, |
+ ), |
+ gclient_scm.GitRefish( |
+ source=hash_value, |
+ is_branch=False, |
+ local_ref=hash_value, |
+ remote='origin', |
+ remote_ref=hash_value, |
+ remote_refspec=hash_value, |
+ upstream_branch=None, |
+ ) |
+ ) |
+ |
+ |
if __name__ == '__main__': |
level = logging.DEBUG if '-v' in sys.argv else logging.FATAL |
logging.basicConfig( |