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

Side by Side Diff: tests/gclient_test.py

Issue 115217: Revert changes 15823 and 15824 because they broke gclient revert. (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') | tests/trychange_unittest.py » ('j') | 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 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 relpath=self.relpath) 1138 relpath=self.relpath)
1139 scm.revert(options, self.args, files_list) 1139 scm.revert(options, self.args, files_list)
1140 self.mox.VerifyAll() 1140 self.mox.VerifyAll()
1141 gclient.os.path.isdir = os.path.isdir 1141 gclient.os.path.isdir = os.path.isdir
1142 1142
1143 def testRevertNone(self): 1143 def testRevertNone(self):
1144 options = self.Options(verbose=True) 1144 options = self.Options(verbose=True)
1145 base_path = os.path.join(self.root_dir, self.relpath) 1145 base_path = os.path.join(self.root_dir, self.relpath)
1146 gclient.os.path.isdir = self.mox.CreateMockAnything() 1146 gclient.os.path.isdir = self.mox.CreateMockAnything()
1147 gclient.os.path.isdir(base_path).AndReturn(True) 1147 gclient.os.path.isdir(base_path).AndReturn(True)
1148 gclient.CaptureSVNStatus(base_path).AndReturn([]) 1148 gclient.CaptureSVNStatus(options, base_path).AndReturn([])
1149 1149
1150 self.mox.ReplayAll() 1150 self.mox.ReplayAll()
1151 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, 1151 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir,
1152 relpath=self.relpath) 1152 relpath=self.relpath)
1153 file_list = [] 1153 file_list = []
1154 scm.revert(options, self.args, file_list) 1154 scm.revert(options, self.args, file_list)
1155 self.mox.VerifyAll() 1155 self.mox.VerifyAll()
1156 gclient.os.path.isdir = os.path.isdir 1156 gclient.os.path.isdir = os.path.isdir
1157 1157
1158 def testRevert2Files(self): 1158 def testRevert2Files(self):
1159 options = self.Options(verbose=True) 1159 options = self.Options(verbose=True)
1160 base_path = os.path.join(self.root_dir, self.relpath) 1160 base_path = os.path.join(self.root_dir, self.relpath)
1161 gclient.os.path.isdir = self.mox.CreateMockAnything() 1161 gclient.os.path.isdir = self.mox.CreateMockAnything()
1162 gclient.os.path.isdir(base_path).AndReturn(True) 1162 gclient.os.path.isdir(base_path).AndReturn(True)
1163 items = [ 1163 items = [
1164 gclient.FileStatus('a', 'M', ' ', ' ', ' '), 1164 gclient.FileStatus('a', 'M', ' ', ' ', ' '),
1165 gclient.FileStatus('b', 'A', ' ', ' ', ' '), 1165 gclient.FileStatus('b', 'A', ' ', ' ', ' '),
1166 ] 1166 ]
1167 gclient.CaptureSVNStatus(base_path).AndReturn(items) 1167 gclient.CaptureSVNStatus(options, base_path).AndReturn(items)
1168 1168
1169 print >>options.stdout, os.path.join(base_path, 'a') 1169 print >>options.stdout, os.path.join(base_path, 'a')
1170 print >>options.stdout, os.path.join(base_path, 'b') 1170 print >>options.stdout, os.path.join(base_path, 'b')
1171 gclient.RunSVN(['revert', 'a', 'b'], base_path) 1171 gclient.RunSVN(options, ['revert', 'a', 'b'], base_path)
1172 1172
1173 self.mox.ReplayAll() 1173 self.mox.ReplayAll()
1174 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, 1174 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir,
1175 relpath=self.relpath) 1175 relpath=self.relpath)
1176 file_list = [] 1176 file_list = []
1177 scm.revert(options, self.args, file_list) 1177 scm.revert(options, self.args, file_list)
1178 self.mox.VerifyAll() 1178 self.mox.VerifyAll()
1179 gclient.os.path.isdir = os.path.isdir 1179 gclient.os.path.isdir = os.path.isdir
1180 1180
1181 def testStatus(self): 1181 def testStatus(self):
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 options.force = True 1222 options.force = True
1223 file_info = { 1223 file_info = {
1224 'Repository Root': 'blah', 1224 'Repository Root': 'blah',
1225 'URL': self.url, 1225 'URL': self.url,
1226 'UUID': 'ABC', 1226 'UUID': 'ABC',
1227 'Revision': 42, 1227 'Revision': 42,
1228 } 1228 }
1229 options.path_exists(os.path.join(base_path, '.git')).AndReturn(False) 1229 options.path_exists(os.path.join(base_path, '.git')).AndReturn(False)
1230 # Checkout or update. 1230 # Checkout or update.
1231 options.path_exists(base_path).AndReturn(True) 1231 options.path_exists(base_path).AndReturn(True)
1232 gclient.CaptureSVNInfo(os.path.join(base_path, "."), '.' 1232 gclient.CaptureSVNInfo(options, os.path.join(base_path, "."), '.'
1233 ).AndReturn(file_info) 1233 ).AndReturn(file_info)
1234 # Cheat a bit here. 1234 # Cheat a bit here.
1235 gclient.CaptureSVNInfo(file_info['URL'], '.').AndReturn(file_info) 1235 gclient.CaptureSVNInfo(options, file_info['URL'], '.').AndReturn(file_info)
1236 additional_args = [] 1236 additional_args = []
1237 if options.manually_grab_svn_rev: 1237 if options.manually_grab_svn_rev:
1238 additional_args = ['--revision', str(file_info['Revision'])] 1238 additional_args = ['--revision', str(file_info['Revision'])]
1239 files_list = [] 1239 files_list = []
1240 gclient.RunSVNAndGetFileList(options, ['update', base_path] + additional_arg s, 1240 gclient.RunSVNAndGetFileList(options, ['update', base_path] + additional_arg s,
1241 self.root_dir, files_list) 1241 self.root_dir, files_list)
1242 1242
1243 self.mox.ReplayAll() 1243 self.mox.ReplayAll()
1244 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, 1244 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir,
1245 relpath=self.relpath) 1245 relpath=self.relpath)
(...skipping 23 matching lines...) Expand all
1269 <wc-info> 1269 <wc-info>
1270 <schedule>add</schedule> 1270 <schedule>add</schedule>
1271 <depth>infinity</depth> 1271 <depth>infinity</depth>
1272 <copy-from-url>http://src.chromium.org/svn/trunk/src/chrome/app/DEPS</copy-from- url> 1272 <copy-from-url>http://src.chromium.org/svn/trunk/src/chrome/app/DEPS</copy-from- url>
1273 <copy-from-rev>14628</copy-from-rev> 1273 <copy-from-rev>14628</copy-from-rev>
1274 <checksum>369f59057ba0e6d9017e28f8bdfb1f43</checksum> 1274 <checksum>369f59057ba0e6d9017e28f8bdfb1f43</checksum>
1275 </wc-info> 1275 </wc-info>
1276 </entry> 1276 </entry>
1277 </info> 1277 </info>
1278 """ % self.url 1278 """ % self.url
1279 gclient.CaptureSVN(['info', '--xml', self.url], 1279 options = self.Options(verbose=True)
1280 '.', True).AndReturn(xml_text) 1280 gclient.CaptureSVN(options, ['info', '--xml', self.url],
1281 '.').AndReturn(xml_text)
1281 expected = { 1282 expected = {
1282 'URL': 'http://src.chromium.org/svn/trunk/src/chrome/app/d', 1283 'URL': 'http://src.chromium.org/svn/trunk/src/chrome/app/d',
1283 'UUID': None, 1284 'UUID': None,
1284 'Repository Root': 'http://src.chromium.org/svn', 1285 'Repository Root': 'http://src.chromium.org/svn',
1285 'Schedule': 'add', 1286 'Schedule': 'add',
1286 'Copied From URL': 'http://src.chromium.org/svn/trunk/src/chrome/app/DEPS' , 1287 'Copied From URL': 'http://src.chromium.org/svn/trunk/src/chrome/app/DEPS' ,
1287 'Copied From Rev': '14628', 1288 'Copied From Rev': '14628',
1288 'Path': self.url, 1289 'Path': self.url,
1289 'Revision': 14628, 1290 'Revision': 14628,
1290 'Node Kind': 'file', 1291 'Node Kind': 'file',
1291 } 1292 }
1292 self.mox.ReplayAll() 1293 self.mox.ReplayAll()
1293 file_info = self._CaptureSVNInfo(self.url, '.', True) 1294 file_info = self._CaptureSVNInfo(options, self.url, '.')
1294 self.assertEquals(sorted(file_info.items()), sorted(expected.items())) 1295 self.assertEquals(sorted(file_info.items()), sorted(expected.items()))
1295 self.mox.VerifyAll() 1296 self.mox.VerifyAll()
1296 1297
1297 def testCaptureSvnInfo(self): 1298 def testCaptureSvnInfo(self):
1298 xml_text = """<?xml version="1.0"?> 1299 xml_text = """<?xml version="1.0"?>
1299 <info> 1300 <info>
1300 <entry 1301 <entry
1301 kind="dir" 1302 kind="dir"
1302 path="." 1303 path="."
1303 revision="35"> 1304 revision="35">
1304 <url>%s</url> 1305 <url>%s</url>
1305 <repository> 1306 <repository>
1306 <root>%s</root> 1307 <root>%s</root>
1307 <uuid>7b9385f5-0452-0410-af26-ad4892b7a1fb</uuid> 1308 <uuid>7b9385f5-0452-0410-af26-ad4892b7a1fb</uuid>
1308 </repository> 1309 </repository>
1309 <wc-info> 1310 <wc-info>
1310 <schedule>normal</schedule> 1311 <schedule>normal</schedule>
1311 <depth>infinity</depth> 1312 <depth>infinity</depth>
1312 </wc-info> 1313 </wc-info>
1313 <commit 1314 <commit
1314 revision="35"> 1315 revision="35">
1315 <author>maruel</author> 1316 <author>maruel</author>
1316 <date>2008-12-04T20:12:19.685120Z</date> 1317 <date>2008-12-04T20:12:19.685120Z</date>
1317 </commit> 1318 </commit>
1318 </entry> 1319 </entry>
1319 </info> 1320 </info>
1320 """ % (self.url, self.root_dir) 1321 """ % (self.url, self.root_dir)
1321 gclient.CaptureSVN(['info', '--xml', self.url], 1322 options = self.Options(verbose=True)
1322 '.', True).AndReturn(xml_text) 1323 gclient.CaptureSVN(options, ['info', '--xml', self.url],
1324 '.').AndReturn(xml_text)
1323 self.mox.ReplayAll() 1325 self.mox.ReplayAll()
1324 file_info = self._CaptureSVNInfo(self.url, '.', True) 1326 file_info = self._CaptureSVNInfo(options, self.url, '.')
1325 expected = { 1327 expected = {
1326 'URL': self.url, 1328 'URL': self.url,
1327 'UUID': '7b9385f5-0452-0410-af26-ad4892b7a1fb', 1329 'UUID': '7b9385f5-0452-0410-af26-ad4892b7a1fb',
1328 'Revision': 35, 1330 'Revision': 35,
1329 'Repository Root': self.root_dir, 1331 'Repository Root': self.root_dir,
1330 'Schedule': 'normal', 1332 'Schedule': 'normal',
1331 'Copied From URL': None, 1333 'Copied From URL': None,
1332 'Copied From Rev': None, 1334 'Copied From Rev': None,
1333 'Path': '.', 1335 'Path': '.',
1334 'Node Kind': 'dir', 1336 'Node Kind': 'dir',
1335 } 1337 }
1336 self.assertEqual(file_info, expected) 1338 self.assertEqual(file_info, expected)
1337 self.mox.VerifyAll() 1339 self.mox.VerifyAll()
1338 1340
1339 1341
1340 if __name__ == '__main__': 1342 if __name__ == '__main__':
1341 unittest.main() 1343 unittest.main()
1342 1344
1343 # vim: ts=2:sw=2:tw=80:et: 1345 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « tests/gcl_unittest.py ('k') | tests/trychange_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698