gclient_scm_test.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. #!/usr/bin/python
  2. # Copyright (c) 2010 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. """Unit tests for gclient_scm.py."""
  6. # Import before super_mox to keep valid references.
  7. from os import rename
  8. from shutil import rmtree
  9. from subprocess import Popen, PIPE, STDOUT
  10. import tempfile
  11. # Fixes include path.
  12. from super_mox import mox, SuperMoxBaseTestBase
  13. import gclient_scm
  14. from gclient_test import BaseTestCase as GCBaseTestCase
  15. class BaseTestCase(GCBaseTestCase):
  16. def setUp(self):
  17. GCBaseTestCase.setUp(self)
  18. self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileRead')
  19. self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileWrite')
  20. self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'SubprocessCall')
  21. self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'RemoveDirectory')
  22. self._CaptureSVNInfo = gclient_scm.scm.SVN.CaptureInfo
  23. self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'Capture')
  24. self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'CaptureInfo')
  25. self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'CaptureStatus')
  26. self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'Run')
  27. self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'RunAndGetFileList')
  28. self._scm_wrapper = gclient_scm.CreateSCM
  29. class SVNWrapperTestCase(BaseTestCase):
  30. class OptionsObject(object):
  31. def __init__(self, test_case, verbose=False, revision=None):
  32. self.verbose = verbose
  33. self.revision = revision
  34. self.manually_grab_svn_rev = True
  35. self.deps_os = None
  36. self.force = False
  37. self.nohooks = False
  38. def Options(self, *args, **kwargs):
  39. return self.OptionsObject(self, *args, **kwargs)
  40. def setUp(self):
  41. BaseTestCase.setUp(self)
  42. self.root_dir = self.Dir()
  43. self.args = self.Args()
  44. self.url = self.Url()
  45. self.relpath = 'asf'
  46. def testDir(self):
  47. members = [
  48. 'COMMAND', 'Capture', 'CaptureHeadRevision', 'CaptureInfo',
  49. 'CaptureStatus', 'DiffItem', 'GenerateDiff', 'GetCheckoutRoot',
  50. 'GetEmail', 'GetFileProperty', 'FullUrlForRelativeUrl', 'IsMoved',
  51. 'ReadSimpleAuth', 'Run', 'RunAndFilterOutput', 'RunAndGetFileList',
  52. 'RunCommand', 'cleanup', 'diff', 'export', 'pack', 'relpath', 'revert',
  53. 'revinfo', 'runhooks', 'scm_name', 'status', 'update', 'url',
  54. ]
  55. # If you add a member, be sure to add the relevant test!
  56. self.compareMembers(self._scm_wrapper(), members)
  57. def testUnsupportedSCM(self):
  58. args = [self.url, self.root_dir, self.relpath]
  59. kwargs = {'scm_name' : 'foo'}
  60. exception_msg = 'Unsupported scm %(scm_name)s' % kwargs
  61. self.assertRaisesError(exception_msg, self._scm_wrapper, *args, **kwargs)
  62. def testSVNFullUrlForRelativeUrl(self):
  63. self.url = 'svn://a/b/c/d'
  64. self.mox.ReplayAll()
  65. scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
  66. relpath=self.relpath)
  67. self.assertEqual(scm.FullUrlForRelativeUrl('/crap'), 'svn://a/b/crap')
  68. def testGITFullUrlForRelativeUrl(self):
  69. self.url = 'git://a/b/c/d'
  70. self.mox.ReplayAll()
  71. scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
  72. relpath=self.relpath)
  73. self.assertEqual(scm.FullUrlForRelativeUrl('/crap'), 'git://a/b/c/crap')
  74. def testRunCommandException(self):
  75. options = self.Options(verbose=False)
  76. file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.git')
  77. gclient_scm.os.path.exists(file_path).AndReturn(False)
  78. self.mox.ReplayAll()
  79. scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
  80. relpath=self.relpath)
  81. exception = "Unsupported argument(s): %s" % ','.join(self.args)
  82. self.assertRaisesError(exception, scm.RunCommand,
  83. 'update', options, self.args)
  84. def testRunCommandUnknown(self):
  85. # TODO(maruel): if ever used.
  86. pass
  87. def testRevertMissing(self):
  88. options = self.Options(verbose=True)
  89. base_path = gclient_scm.os.path.join(self.root_dir, self.relpath)
  90. gclient_scm.os.path.isdir(base_path).AndReturn(False)
  91. # It'll to a checkout instead.
  92. gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git')
  93. ).AndReturn(False)
  94. print("\n_____ %s is missing, synching instead" % self.relpath)
  95. # Checkout.
  96. gclient_scm.os.path.exists(base_path).AndReturn(False)
  97. files_list = self.mox.CreateMockAnything()
  98. gclient_scm.scm.SVN.RunAndGetFileList(options,
  99. ['checkout', self.url, base_path],
  100. self.root_dir, files_list)
  101. self.mox.ReplayAll()
  102. scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
  103. relpath=self.relpath)
  104. scm.revert(options, self.args, files_list)
  105. def testRevertNone(self):
  106. options = self.Options(verbose=True)
  107. base_path = gclient_scm.os.path.join(self.root_dir, self.relpath)
  108. gclient_scm.os.path.isdir(base_path).AndReturn(True)
  109. gclient_scm.scm.SVN.CaptureStatus(base_path).AndReturn([])
  110. gclient_scm.scm.SVN.RunAndGetFileList(options,
  111. ['update', '--revision', 'BASE'],
  112. base_path, mox.IgnoreArg())
  113. self.mox.ReplayAll()
  114. scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
  115. relpath=self.relpath)
  116. file_list = []
  117. scm.revert(options, self.args, file_list)
  118. def testRevert2Files(self):
  119. options = self.Options(verbose=True)
  120. base_path = gclient_scm.os.path.join(self.root_dir, self.relpath)
  121. gclient_scm.os.path.isdir(base_path).AndReturn(True)
  122. items = [
  123. ('M ', 'a'),
  124. ('A ', 'b'),
  125. ]
  126. file_path1 = gclient_scm.os.path.join(base_path, 'a')
  127. file_path2 = gclient_scm.os.path.join(base_path, 'b')
  128. gclient_scm.scm.SVN.CaptureStatus(base_path).AndReturn(items)
  129. gclient_scm.os.path.exists(file_path1).AndReturn(True)
  130. gclient_scm.os.path.isfile(file_path1).AndReturn(True)
  131. gclient_scm.os.remove(file_path1)
  132. gclient_scm.os.path.exists(file_path2).AndReturn(True)
  133. gclient_scm.os.path.isfile(file_path2).AndReturn(True)
  134. gclient_scm.os.remove(file_path2)
  135. gclient_scm.scm.SVN.RunAndGetFileList(options,
  136. ['update', '--revision', 'BASE'],
  137. base_path, mox.IgnoreArg())
  138. print(gclient_scm.os.path.join(base_path, 'a'))
  139. print(gclient_scm.os.path.join(base_path, 'b'))
  140. self.mox.ReplayAll()
  141. scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
  142. relpath=self.relpath)
  143. file_list = []
  144. scm.revert(options, self.args, file_list)
  145. def testRevertDirectory(self):
  146. options = self.Options(verbose=True)
  147. base_path = gclient_scm.os.path.join(self.root_dir, self.relpath)
  148. gclient_scm.os.path.isdir(base_path).AndReturn(True)
  149. items = [
  150. ('~ ', 'a'),
  151. ]
  152. gclient_scm.scm.SVN.CaptureStatus(base_path).AndReturn(items)
  153. file_path = gclient_scm.os.path.join(base_path, 'a')
  154. print(file_path)
  155. gclient_scm.os.path.exists(file_path).AndReturn(True)
  156. gclient_scm.os.path.isfile(file_path).AndReturn(False)
  157. gclient_scm.os.path.islink(file_path).AndReturn(False)
  158. gclient_scm.os.path.isdir(file_path).AndReturn(True)
  159. gclient_scm.gclient_utils.RemoveDirectory(file_path)
  160. file_list1 = []
  161. gclient_scm.scm.SVN.RunAndGetFileList(options,
  162. ['update', '--revision', 'BASE'],
  163. base_path, mox.IgnoreArg())
  164. self.mox.ReplayAll()
  165. scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
  166. relpath=self.relpath)
  167. file_list2 = []
  168. scm.revert(options, self.args, file_list2)
  169. def testStatus(self):
  170. options = self.Options(verbose=True)
  171. base_path = gclient_scm.os.path.join(self.root_dir, self.relpath)
  172. gclient_scm.os.path.isdir(base_path).AndReturn(True)
  173. gclient_scm.scm.SVN.RunAndGetFileList(options,
  174. ['status'] + self.args,
  175. base_path, []).AndReturn(None)
  176. self.mox.ReplayAll()
  177. scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
  178. relpath=self.relpath)
  179. file_list = []
  180. self.assertEqual(scm.status(options, self.args, file_list), None)
  181. # TODO(maruel): TEST REVISIONS!!!
  182. # TODO(maruel): TEST RELOCATE!!!
  183. def testUpdateCheckout(self):
  184. options = self.Options(verbose=True)
  185. base_path = gclient_scm.os.path.join(self.root_dir, self.relpath)
  186. file_info = gclient_scm.gclient_utils.PrintableObject()
  187. file_info.root = 'blah'
  188. file_info.url = self.url
  189. file_info.uuid = 'ABC'
  190. file_info.revision = 42
  191. gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git')
  192. ).AndReturn(False)
  193. # Checkout.
  194. gclient_scm.os.path.exists(base_path).AndReturn(False)
  195. files_list = self.mox.CreateMockAnything()
  196. gclient_scm.scm.SVN.RunAndGetFileList(options,
  197. ['checkout', self.url, base_path],
  198. self.root_dir, files_list)
  199. self.mox.ReplayAll()
  200. scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
  201. relpath=self.relpath)
  202. scm.update(options, (), files_list)
  203. def testUpdateUpdate(self):
  204. options = self.Options(verbose=True)
  205. base_path = gclient_scm.os.path.join(self.root_dir, self.relpath)
  206. options.force = True
  207. options.nohooks = False
  208. file_info = {
  209. 'Repository Root': 'blah',
  210. 'URL': self.url,
  211. 'UUID': 'ABC',
  212. 'Revision': 42,
  213. }
  214. gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git')
  215. ).AndReturn(False)
  216. # Checkout or update.
  217. gclient_scm.os.path.exists(base_path).AndReturn(True)
  218. gclient_scm.scm.SVN.CaptureInfo(
  219. gclient_scm.os.path.join(base_path, "."), '.'
  220. ).AndReturn(file_info)
  221. # Cheat a bit here.
  222. gclient_scm.scm.SVN.CaptureInfo(file_info['URL'], '.').AndReturn(file_info)
  223. additional_args = []
  224. if options.manually_grab_svn_rev:
  225. additional_args = ['--revision', str(file_info['Revision'])]
  226. files_list = []
  227. gclient_scm.scm.SVN.RunAndGetFileList(
  228. options,
  229. ['update', base_path] + additional_args,
  230. self.root_dir, files_list)
  231. self.mox.ReplayAll()
  232. scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
  233. relpath=self.relpath)
  234. scm.update(options, (), files_list)
  235. def testUpdateGit(self):
  236. options = self.Options(verbose=True)
  237. file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.git')
  238. gclient_scm.os.path.exists(file_path).AndReturn(True)
  239. print("________ found .git directory; skipping %s" % self.relpath)
  240. self.mox.ReplayAll()
  241. scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
  242. relpath=self.relpath)
  243. file_list = []
  244. scm.update(options, self.args, file_list)
  245. class GitWrapperTestCase(BaseTestCase):
  246. """This class doesn't use pymox."""
  247. class OptionsObject(object):
  248. def __init__(self, test_case, verbose=False, revision=None):
  249. self.verbose = verbose
  250. self.revision = revision
  251. self.manually_grab_svn_rev = True
  252. self.deps_os = None
  253. self.force = False
  254. self.nohooks = False
  255. sample_git_import = """blob
  256. mark :1
  257. data 6
  258. Hello
  259. blob
  260. mark :2
  261. data 4
  262. Bye
  263. reset refs/heads/master
  264. commit refs/heads/master
  265. mark :3
  266. author Bob <bob@example.com> 1253744361 -0700
  267. committer Bob <bob@example.com> 1253744361 -0700
  268. data 8
  269. A and B
  270. M 100644 :1 a
  271. M 100644 :2 b
  272. blob
  273. mark :4
  274. data 10
  275. Hello
  276. You
  277. blob
  278. mark :5
  279. data 8
  280. Bye
  281. You
  282. commit refs/heads/origin
  283. mark :6
  284. author Alice <alice@example.com> 1253744424 -0700
  285. committer Alice <alice@example.com> 1253744424 -0700
  286. data 13
  287. Personalized
  288. from :3
  289. M 100644 :4 a
  290. M 100644 :5 b
  291. reset refs/heads/master
  292. from :3
  293. """
  294. def Options(self, *args, **kwargs):
  295. return self.OptionsObject(self, *args, **kwargs)
  296. def CreateGitRepo(self, git_import, path):
  297. """Do it for real."""
  298. try:
  299. Popen(['git', 'init'], stdout=PIPE, stderr=STDOUT,
  300. cwd=path).communicate()
  301. except OSError:
  302. # git is not available, skip this test.
  303. return False
  304. Popen(['git', 'fast-import'], stdin=PIPE, stdout=PIPE, stderr=STDOUT,
  305. cwd=path).communicate(input=git_import)
  306. Popen(['git', 'checkout'], stdout=PIPE, stderr=STDOUT,
  307. cwd=path).communicate()
  308. return True
  309. def setUp(self):
  310. self.args = self.Args()
  311. self.url = 'git://foo'
  312. self.root_dir = tempfile.mkdtemp()
  313. self.relpath = '.'
  314. self.base_path = gclient_scm.os.path.join(self.root_dir, self.relpath)
  315. self.enabled = self.CreateGitRepo(self.sample_git_import, self.base_path)
  316. SuperMoxBaseTestBase.setUp(self)
  317. def tearDown(self):
  318. SuperMoxBaseTestBase.tearDown(self)
  319. rmtree(self.root_dir)
  320. def testDir(self):
  321. members = [
  322. 'COMMAND', 'Capture', 'CaptureStatus', 'FetchUpstreamTuple',
  323. 'FullUrlForRelativeUrl', 'GenerateDiff', 'GetBranch', 'GetBranchRef',
  324. 'GetCheckoutRoot', 'GetDifferentFiles', 'GetEmail', 'GetPatchName',
  325. 'GetSVNBranch', 'GetUpstream', 'IsGitSvn', 'RunAndFilterOutput',
  326. 'ShortBranchName', 'RunCommand',
  327. 'cleanup', 'diff', 'export', 'pack', 'relpath', 'revert',
  328. 'revinfo', 'runhooks', 'scm_name', 'status', 'update', 'url',
  329. ]
  330. # If you add a member, be sure to add the relevant test!
  331. self.compareMembers(gclient_scm.CreateSCM(url=self.url), members)
  332. def testRevertMissing(self):
  333. if not self.enabled:
  334. return
  335. options = self.Options()
  336. file_path = gclient_scm.os.path.join(self.base_path, 'a')
  337. gclient_scm.os.remove(file_path)
  338. scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
  339. relpath=self.relpath)
  340. file_list = []
  341. scm.revert(options, self.args, file_list)
  342. self.assertEquals(file_list, [file_path])
  343. file_list = []
  344. scm.diff(options, self.args, file_list)
  345. self.assertEquals(file_list, [])
  346. def testRevertNone(self):
  347. if not self.enabled:
  348. return
  349. options = self.Options()
  350. scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
  351. relpath=self.relpath)
  352. file_list = []
  353. scm.revert(options, self.args, file_list)
  354. self.assertEquals(file_list, [])
  355. self.assertEquals(scm.revinfo(options, self.args, None),
  356. '069c602044c5388d2d15c3f875b057c852003458')
  357. def testRevertModified(self):
  358. if not self.enabled:
  359. return
  360. options = self.Options()
  361. file_path = gclient_scm.os.path.join(self.base_path, 'a')
  362. open(file_path, 'a').writelines('touched\n')
  363. scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
  364. relpath=self.relpath)
  365. file_list = []
  366. scm.revert(options, self.args, file_list)
  367. self.assertEquals(file_list, [file_path])
  368. file_list = []
  369. scm.diff(options, self.args, file_list)
  370. self.assertEquals(file_list, [])
  371. self.assertEquals(scm.revinfo(options, self.args, None),
  372. '069c602044c5388d2d15c3f875b057c852003458')
  373. def testRevertNew(self):
  374. if not self.enabled:
  375. return
  376. options = self.Options()
  377. file_path = gclient_scm.os.path.join(self.base_path, 'c')
  378. f = open(file_path, 'w')
  379. f.writelines('new\n')
  380. f.close()
  381. Popen(['git', 'add', 'c'], stdout=PIPE,
  382. stderr=STDOUT, cwd=self.base_path).communicate()
  383. scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
  384. relpath=self.relpath)
  385. file_list = []
  386. scm.revert(options, self.args, file_list)
  387. self.assertEquals(file_list, [file_path])
  388. file_list = []
  389. scm.diff(options, self.args, file_list)
  390. self.assertEquals(file_list, [])
  391. self.assertEquals(scm.revinfo(options, self.args, None),
  392. '069c602044c5388d2d15c3f875b057c852003458')
  393. def testStatusNew(self):
  394. if not self.enabled:
  395. return
  396. options = self.Options()
  397. file_path = gclient_scm.os.path.join(self.base_path, 'a')
  398. open(file_path, 'a').writelines('touched\n')
  399. scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
  400. relpath=self.relpath)
  401. file_list = []
  402. scm.status(options, self.args, file_list)
  403. self.assertEquals(file_list, [file_path])
  404. def testStatus2New(self):
  405. if not self.enabled:
  406. return
  407. options = self.Options()
  408. expected_file_list = []
  409. for f in ['a', 'b']:
  410. file_path = gclient_scm.os.path.join(self.base_path, f)
  411. open(file_path, 'a').writelines('touched\n')
  412. expected_file_list.extend([file_path])
  413. scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
  414. relpath=self.relpath)
  415. file_list = []
  416. scm.status(options, self.args, file_list)
  417. expected_file_list = [gclient_scm.os.path.join(self.base_path, x)
  418. for x in ['a', 'b']]
  419. self.assertEquals(sorted(file_list), expected_file_list)
  420. def testUpdateCheckout(self):
  421. if not self.enabled:
  422. return
  423. options = self.Options(verbose=True)
  424. root_dir = tempfile.mkdtemp()
  425. relpath = 'foo'
  426. base_path = gclient_scm.os.path.join(root_dir, relpath)
  427. url = gclient_scm.os.path.join(self.root_dir, self.relpath, '.git')
  428. try:
  429. scm = gclient_scm.CreateSCM(url=url, root_dir=root_dir,
  430. relpath=relpath)
  431. file_list = []
  432. scm.update(options, (), file_list)
  433. self.assertEquals(len(file_list), 2)
  434. self.assert_(gclient_scm.os.path.isfile(
  435. gclient_scm.os.path.join(base_path, 'a')))
  436. self.assertEquals(scm.revinfo(options, (), None),
  437. '069c602044c5388d2d15c3f875b057c852003458')
  438. finally:
  439. rmtree(root_dir)
  440. def testUpdateUpdate(self):
  441. if not self.enabled:
  442. return
  443. options = self.Options()
  444. expected_file_list = [gclient_scm.os.path.join(self.base_path, x)
  445. for x in ['a', 'b']]
  446. scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
  447. relpath=self.relpath)
  448. file_list = []
  449. scm.update(options, (), file_list)
  450. self.assertEquals(file_list, expected_file_list)
  451. self.assertEquals(scm.revinfo(options, (), None),
  452. 'a7142dc9f0009350b96a11f372b6ea658592aa95')
  453. def testUpdateConflict(self):
  454. if not self.enabled:
  455. return
  456. options = self.Options()
  457. scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
  458. relpath=self.relpath)
  459. file_path = gclient_scm.os.path.join(self.base_path, 'b')
  460. f = open(file_path, 'w').writelines('conflict\n')
  461. scm._Run(['commit', '-am', 'test'])
  462. exception = \
  463. '\n____ .\n' \
  464. '\nConflict while rebasing this branch.\n' \
  465. 'Fix the conflict and run gclient again.\n' \
  466. 'See man git-rebase for details.\n'
  467. self.assertRaisesError(exception, scm.update, options, (), [])
  468. exception = \
  469. '\n____ .\n' \
  470. '\tAlready in a conflict, i.e. (no branch).\n' \
  471. '\tFix the conflict and run gclient again.\n' \
  472. '\tOr to abort run:\n\t\tgit-rebase --abort\n' \
  473. '\tSee man git-rebase for details.\n'
  474. self.assertRaisesError(exception, scm.update, options, (), [])
  475. def testUpdateNotGit(self):
  476. if not self.enabled:
  477. return
  478. options = self.Options()
  479. scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
  480. relpath=self.relpath)
  481. git_path = gclient_scm.os.path.join(self.base_path, '.git')
  482. rename(git_path, git_path + 'foo')
  483. exception = \
  484. '\n____ .\n' \
  485. '\tPath is not a git repo. No .git dir.\n' \
  486. '\tTo resolve:\n' \
  487. '\t\trm -rf .\n' \
  488. '\tAnd run gclient sync again\n'
  489. self.assertRaisesError(exception, scm.update, options, (), [])
  490. def testRevinfo(self):
  491. if not self.enabled:
  492. return
  493. options = self.Options()
  494. scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
  495. relpath=self.relpath)
  496. rev_info = scm.revinfo(options, (), None)
  497. self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458')
  498. if __name__ == '__main__':
  499. import unittest
  500. unittest.main()
  501. # vim: ts=2:sw=2:tw=80:et: