OLD | NEW |
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 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 scm, 'update', options, self.args) | 1114 scm, 'update', options, self.args) |
1115 self.mox.VerifyAll() | 1115 self.mox.VerifyAll() |
1116 | 1116 |
1117 def testRunCommandUnknown(self): | 1117 def testRunCommandUnknown(self): |
1118 # TODO(maruel): if ever used. | 1118 # TODO(maruel): if ever used. |
1119 pass | 1119 pass |
1120 | 1120 |
1121 def testRevertMissing(self): | 1121 def testRevertMissing(self): |
1122 options = self.Options(verbose=True) | 1122 options = self.Options(verbose=True) |
1123 gclient.os.path.isdir = self.mox.CreateMockAnything() | 1123 gclient.os.path.isdir = self.mox.CreateMockAnything() |
1124 gclient.os.path.isdir(os.path.join(self.root_dir, self.relpath) | 1124 base_path = os.path.join(self.root_dir, self.relpath) |
1125 ).AndReturn(False) | 1125 gclient.os.path.isdir(base_path).AndReturn(False) |
1126 print >>options.stdout, ("\n_____ %s is missing, can't revert" % | 1126 # It'll to a checkout instead. |
| 1127 options.path_exists(os.path.join(base_path, '.git')).AndReturn(False) |
| 1128 print >>options.stdout, ("\n_____ %s is missing, synching instead" % |
1127 self.relpath) | 1129 self.relpath) |
| 1130 # Checkout. |
| 1131 options.path_exists(base_path).AndReturn(False) |
| 1132 files_list = self.mox.CreateMockAnything() |
| 1133 gclient.RunSVNAndGetFileList(options, ['checkout', self.url, base_path], |
| 1134 self.root_dir, files_list) |
1128 | 1135 |
1129 self.mox.ReplayAll() | 1136 self.mox.ReplayAll() |
1130 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, | 1137 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, |
1131 relpath=self.relpath) | 1138 relpath=self.relpath) |
1132 file_list = [] | 1139 scm.revert(options, self.args, files_list) |
1133 scm.revert(options, self.args, file_list) | |
1134 self.mox.VerifyAll() | 1140 self.mox.VerifyAll() |
1135 gclient.os.path.isdir = os.path.isdir | 1141 gclient.os.path.isdir = os.path.isdir |
1136 | 1142 |
1137 def testRevertNone(self): | 1143 def testRevertNone(self): |
1138 options = self.Options(verbose=True) | 1144 options = self.Options(verbose=True) |
1139 base_path = os.path.join(self.root_dir, self.relpath) | 1145 base_path = os.path.join(self.root_dir, self.relpath) |
1140 gclient.os.path.isdir = self.mox.CreateMockAnything() | 1146 gclient.os.path.isdir = self.mox.CreateMockAnything() |
1141 gclient.os.path.isdir(base_path).AndReturn(True) | 1147 gclient.os.path.isdir(base_path).AndReturn(True) |
1142 gclient.CaptureSVNStatus(options, base_path).AndReturn([]) | 1148 gclient.CaptureSVNStatus(options, base_path).AndReturn([]) |
1143 | 1149 |
1144 self.mox.ReplayAll() | 1150 self.mox.ReplayAll() |
1145 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, | 1151 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, |
1146 relpath=self.relpath) | 1152 relpath=self.relpath) |
1147 file_list = [] | 1153 file_list = [] |
1148 scm.revert(options, self.args, file_list) | 1154 scm.revert(options, self.args, file_list) |
1149 self.mox.VerifyAll() | 1155 self.mox.VerifyAll() |
1150 gclient.os.path.isdir = os.path.isdir | 1156 gclient.os.path.isdir = os.path.isdir |
1151 | 1157 |
1152 def testRevert2Files(self): | 1158 def testRevert2Files(self): |
1153 options = self.Options(verbose=True) | 1159 options = self.Options(verbose=True) |
1154 base_path = os.path.join(self.root_dir, self.relpath) | 1160 base_path = os.path.join(self.root_dir, self.relpath) |
1155 gclient.os.path.isdir = self.mox.CreateMockAnything() | 1161 gclient.os.path.isdir = self.mox.CreateMockAnything() |
1156 gclient.os.path.isdir(base_path).AndReturn(True) | 1162 gclient.os.path.isdir(base_path).AndReturn(True) |
1157 items = [ | 1163 items = [ |
1158 gclient.FileStatus('a', 'M', ' ', ' '), | 1164 gclient.FileStatus('a', 'M', ' ', ' ', ' '), |
1159 gclient.FileStatus('b', 'A', ' ', ' '), | 1165 gclient.FileStatus('b', 'A', ' ', ' ', ' '), |
1160 ] | 1166 ] |
1161 gclient.CaptureSVNStatus(options, base_path).AndReturn(items) | 1167 gclient.CaptureSVNStatus(options, base_path).AndReturn(items) |
1162 | 1168 |
1163 print >>options.stdout, os.path.join(base_path, 'a') | 1169 print >>options.stdout, os.path.join(base_path, 'a') |
1164 print >>options.stdout, os.path.join(base_path, 'b') | 1170 print >>options.stdout, os.path.join(base_path, 'b') |
1165 gclient.RunSVN(options, ['revert', 'a', 'b'], base_path) | 1171 gclient.RunSVN(options, ['revert', 'a', 'b'], base_path) |
1166 | 1172 |
1167 self.mox.ReplayAll() | 1173 self.mox.ReplayAll() |
1168 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, | 1174 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, |
1169 relpath=self.relpath) | 1175 relpath=self.relpath) |
1170 file_list = [] | 1176 file_list = [] |
1171 scm.revert(options, self.args, file_list) | 1177 scm.revert(options, self.args, file_list) |
1172 self.mox.VerifyAll() | 1178 self.mox.VerifyAll() |
1173 gclient.os.path.isdir = os.path.isdir | 1179 gclient.os.path.isdir = os.path.isdir |
1174 | 1180 |
1175 def testStatus(self): | 1181 def testStatus(self): |
1176 options = self.Options(verbose=True) | 1182 options = self.Options(verbose=True) |
1177 base_path = os.path.join(self.root_dir, self.relpath) | 1183 base_path = os.path.join(self.root_dir, self.relpath) |
| 1184 gclient.os.path.isdir = self.mox.CreateMockAnything() |
| 1185 gclient.os.path.isdir(base_path).AndReturn(True) |
1178 gclient.RunSVNAndGetFileList(options, ['status'] + self.args, base_path, | 1186 gclient.RunSVNAndGetFileList(options, ['status'] + self.args, base_path, |
1179 []).AndReturn(None) | 1187 []).AndReturn(None) |
1180 | 1188 |
1181 self.mox.ReplayAll() | 1189 self.mox.ReplayAll() |
1182 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, | 1190 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, |
1183 relpath=self.relpath) | 1191 relpath=self.relpath) |
1184 file_list = [] | 1192 file_list = [] |
1185 self.assertEqual(scm.status(options, self.args, file_list), None) | 1193 self.assertEqual(scm.status(options, self.args, file_list), None) |
1186 self.mox.VerifyAll() | 1194 self.mox.VerifyAll() |
1187 | 1195 |
1188 | 1196 |
1189 # TODO(maruel): TEST REVISIONS!!! | 1197 # TODO(maruel): TEST REVISIONS!!! |
1190 # TODO(maruel): TEST RELOCATE!!! | 1198 # TODO(maruel): TEST RELOCATE!!! |
1191 def testUpdateCheckout(self): | 1199 def testUpdateCheckout(self): |
1192 options = self.Options(verbose=True) | 1200 options = self.Options(verbose=True) |
1193 base_path = os.path.join(self.root_dir, self.relpath) | 1201 base_path = os.path.join(self.root_dir, self.relpath) |
1194 file_info = gclient.PrintableObject() | 1202 file_info = gclient.PrintableObject() |
1195 file_info.root = 'blah' | 1203 file_info.root = 'blah' |
1196 file_info.url = self.url | 1204 file_info.url = self.url |
1197 file_info.uuid = 'ABC' | 1205 file_info.uuid = 'ABC' |
1198 file_info.revision = 42 | 1206 file_info.revision = 42 |
1199 options.path_exists(os.path.join(base_path, '.git')).AndReturn(False) | 1207 options.path_exists(os.path.join(base_path, '.git')).AndReturn(False) |
1200 # Checkout or update. | 1208 # Checkout. |
1201 options.path_exists(base_path).AndReturn(False) | 1209 options.path_exists(base_path).AndReturn(False) |
1202 print >>options.stdout, "\n_____ asf at 42" | |
1203 #print >>options.stdout, "\n________ running 'svn checkout %s %s' in '%s'" %
( | |
1204 # self.url, base_path, os.path.abspath(self.root_dir)) | |
1205 | |
1206 gclient.CaptureSVNInfo(options, os.path.join(base_path, "."), '.' | |
1207 ).AndReturn(file_info) | |
1208 # Cheat a bit here. | |
1209 gclient.CaptureSVNInfo(options, file_info.url, '.').AndReturn(file_info) | |
1210 files_list = self.mox.CreateMockAnything() | 1210 files_list = self.mox.CreateMockAnything() |
1211 gclient.RunSVNAndGetFileList(options, ['checkout', self.url, base_path], | 1211 gclient.RunSVNAndGetFileList(options, ['checkout', self.url, base_path], |
1212 self.root_dir, files_list) | 1212 self.root_dir, files_list) |
1213 self.mox.ReplayAll() | 1213 self.mox.ReplayAll() |
1214 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, | 1214 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, |
1215 relpath=self.relpath) | 1215 relpath=self.relpath) |
1216 #file_list = [] | |
1217 scm.update(options, (), files_list) | 1216 scm.update(options, (), files_list) |
1218 self.mox.VerifyAll() | 1217 self.mox.VerifyAll() |
1219 | 1218 |
1220 def testUpdateUpdate(self): | 1219 def testUpdateUpdate(self): |
1221 options = self.Options(verbose=True) | 1220 options = self.Options(verbose=True) |
1222 base_path = os.path.join(self.root_dir, self.relpath) | 1221 base_path = os.path.join(self.root_dir, self.relpath) |
1223 options.force = True | 1222 options.force = True |
1224 file_info = gclient.PrintableObject() | 1223 file_info = gclient.PrintableObject() |
1225 file_info.root = 'blah' | 1224 file_info.root = 'blah' |
1226 file_info.url = self.url | 1225 file_info.url = self.url |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 self.failUnless(file_info.url == self.url) | 1292 self.failUnless(file_info.url == self.url) |
1294 self.failUnless(file_info.uuid == '7b9385f5-0452-0410-af26-ad4892b7a1fb') | 1293 self.failUnless(file_info.uuid == '7b9385f5-0452-0410-af26-ad4892b7a1fb') |
1295 self.failUnless(file_info.revision == 35) | 1294 self.failUnless(file_info.revision == 35) |
1296 self.mox.VerifyAll() | 1295 self.mox.VerifyAll() |
1297 | 1296 |
1298 | 1297 |
1299 if __name__ == '__main__': | 1298 if __name__ == '__main__': |
1300 unittest.main() | 1299 unittest.main() |
1301 | 1300 |
1302 # vim: ts=2:sw=2:tw=80:et: | 1301 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |