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

Side by Side Diff: tests/gclient_test.py

Issue 115264: Deprecate gcl.GetSVNStatus() for gclient.CaptureSVNStatus() and fix some stat... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 11 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
« no previous file with comments | « tests/gcl_unittest.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/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright 2008-2009 Google Inc. All Rights Reserved. 3 # Copyright 2008-2009 Google Inc. All Rights Reserved.
4 # 4 #
5 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License. 6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at 7 # You may obtain a copy of the License at
8 # 8 #
9 # http://www.apache.org/licenses/LICENSE-2.0 9 # http://www.apache.org/licenses/LICENSE-2.0
10 # 10 #
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 scm.revert(options, self.args, file_list) 1152 scm.revert(options, self.args, file_list)
1153 self.mox.VerifyAll() 1153 self.mox.VerifyAll()
1154 gclient.os.path.isdir = os.path.isdir 1154 gclient.os.path.isdir = os.path.isdir
1155 1155
1156 def testRevert2Files(self): 1156 def testRevert2Files(self):
1157 options = self.Options(verbose=True) 1157 options = self.Options(verbose=True)
1158 base_path = os.path.join(self.root_dir, self.relpath) 1158 base_path = os.path.join(self.root_dir, self.relpath)
1159 gclient.os.path.isdir = self.mox.CreateMockAnything() 1159 gclient.os.path.isdir = self.mox.CreateMockAnything()
1160 gclient.os.path.isdir(base_path).AndReturn(True) 1160 gclient.os.path.isdir(base_path).AndReturn(True)
1161 items = [ 1161 items = [
1162 gclient.FileStatus('a', 'M', ' ', ' ', ' '), 1162 ('M ', 'a'),
1163 gclient.FileStatus('b', 'A', ' ', ' ', ' '), 1163 ('A ', 'b'),
1164 ] 1164 ]
1165 gclient.CaptureSVNStatus(base_path).AndReturn(items) 1165 gclient.CaptureSVNStatus(base_path).AndReturn(items)
1166 1166
1167 print(os.path.join(base_path, 'a')) 1167 print(os.path.join(base_path, 'a'))
1168 print(os.path.join(base_path, 'b')) 1168 print(os.path.join(base_path, 'b'))
1169 gclient.RunSVN(['revert', 'a', 'b'], base_path) 1169 gclient.RunSVN(['revert', 'a', 'b'], base_path)
1170 1170
1171 self.mox.ReplayAll() 1171 self.mox.ReplayAll()
1172 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, 1172 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir,
1173 relpath=self.relpath) 1173 relpath=self.relpath)
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 gclient.subprocess.Popen(command, bufsize=0, cwd=in_directory, 1380 gclient.subprocess.Popen(command, bufsize=0, cwd=in_directory,
1381 shell=(sys.platform == 'win32'), 1381 shell=(sys.platform == 'win32'),
1382 stdout=gclient.subprocess.PIPE).AndReturn(kid) 1382 stdout=gclient.subprocess.PIPE).AndReturn(kid)
1383 self.mox.ReplayAll() 1383 self.mox.ReplayAll()
1384 capture_list = [] 1384 capture_list = []
1385 gclient.SubprocessCallAndCapture(command, in_directory, fail_status, 1385 gclient.SubprocessCallAndCapture(command, in_directory, fail_status,
1386 pattern, capture_list) 1386 pattern, capture_list)
1387 self.assertEquals(capture_list, ['cc', 'dd']) 1387 self.assertEquals(capture_list, ['cc', 'dd'])
1388 self.mox.VerifyAll() 1388 self.mox.VerifyAll()
1389 1389
1390 def testCaptureSVNStatus(self):
1391 x = self
1392 def CaptureSVNMock(command):
1393 x.assertEquals(['status', '--xml', '.'], command)
1394 return r"""<?xml version="1.0"?>
1395 <status>
1396 <target path=".">
1397 <entry path="unversionned_file.txt">
1398 <wc-status props="none" item="unversioned"></wc-status>
1399 </entry>
1400 <entry path="build\internal\essential.vsprops">
1401 <wc-status props="normal" item="modified" revision="14628">
1402 <commit revision="13818">
1403 <author>ajwong@chromium.org</author>
1404 <date>2009-04-16T00:42:06.872358Z</date>
1405 </commit>
1406 </wc-status>
1407 </entry>
1408 <entry path="chrome\app\d">
1409 <wc-status props="none" copied="true" tree-conflicted="true" item="added">
1410 </wc-status>
1411 </entry>
1412 <entry path="chrome\app\DEPS">
1413 <wc-status props="modified" item="modified" revision="14628">
1414 <commit revision="1279">
1415 <author>brettw@google.com</author>
1416 <date>2008-08-23T17:16:42.090152Z</date>
1417 </commit>
1418 </wc-status>
1419 </entry>
1420 <entry path="scripts\master\factory\gclient_factory.py">
1421 <wc-status props="normal" item="conflicted" revision="14725">
1422 <commit revision="14633">
1423 <author>nsylvain@chromium.org</author>
1424 <date>2009-04-27T19:37:17.977400Z</date>
1425 </commit>
1426 </wc-status>
1427 </entry>
1428 </target>
1429 </status>
1430 """
1431 gclient.CaptureSVN = CaptureSVNMock
1432 info = gclient.CaptureSVNStatus('.')
1433 expected = [
1434 ('? ', 'unversionned_file.txt'),
1435 ('M ', 'build\\internal\\essential.vsprops'),
1436 ('A + ', 'chrome\\app\\d'),
1437 ('MM ', 'chrome\\app\\DEPS'),
1438 ('C ', 'scripts\\master\\factory\\gclient_factory.py'),
1439 ]
1440 self.assertEquals(sorted(info), sorted(expected))
1441
1442 def testCaptureSVNStatusEmpty(self):
1443 x = self
1444 def CaptureSVNMock(command):
1445 x.assertEquals(['status', '--xml'], command)
1446 return r"""<?xml version="1.0"?>
1447 <status>
1448 <target
1449 path="perf">
1450 </target>
1451 </status>
1452 """
1453 gclient.CaptureSVN = CaptureSVNMock
1454 info = gclient.CaptureSVNStatus(None)
1455 self.assertEquals(info, [])
1456
1390 1457
1391 if __name__ == '__main__': 1458 if __name__ == '__main__':
1392 unittest.main() 1459 unittest.main()
1393 1460
1394 # vim: ts=2:sw=2:tw=80:et: 1461 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « tests/gcl_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698