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

Side by Side Diff: tests/gclient_test.py

Issue 1547026: Extend From() to allow importing from different mappings. Also... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 10 years, 8 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 | « gclient.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 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Unit tests for gclient.py.""" 6 """Unit tests for gclient.py."""
7 7
8 # Fixes include path. 8 # Fixes include path.
9 from super_mox import mox, SuperMoxTestBase 9 from super_mox import mox, SuperMoxTestBase
10 10
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 1010
1011 def testRunOnDepsFailureEmpty(self): 1011 def testRunOnDepsFailureEmpty(self):
1012 options = self.Options() 1012 options = self.Options()
1013 1013
1014 self.mox.ReplayAll() 1014 self.mox.ReplayAll()
1015 client = self._gclient_gclient(self.root_dir, options) 1015 client = self._gclient_gclient(self.root_dir, options)
1016 exception = "No solution specified" 1016 exception = "No solution specified"
1017 self.assertRaisesError(exception, self._gclient_gclient.RunOnDeps, client, 1017 self.assertRaisesError(exception, self._gclient_gclient.RunOnDeps, client,
1018 'update', self.args) 1018 'update', self.args)
1019 1019
1020 def testFromImpl(self): 1020 def testFromImplOne(self):
1021 # TODO(maruel): Test me! 1021 base_url = 'svn://base@123'
1022 pass 1022 deps_content = (
1023 "deps = {\n"
1024 " 'base': '%s',\n"
1025 " 'main': From('base'),\n"
1026 "}\n" % base_url
1027 )
1028 main_url = 'svn://main@456'
1029 base_deps_content = (
1030 "deps = {\n"
1031 " 'main': '%s',\n"
1032 "}\n" % main_url
1033 )
1034 # Fake .gclient file.
1035 name = 'testFromImplOne_solution_name'
1036 gclient_config = (
1037 "solutions = [ {\n"
1038 "'name': '%s',\n"
1039 "'url': '%s',\n"
1040 "'custom_deps': {},\n"
1041 "}, ]" % (name, self.url))
1042
1043 options = self.Options()
1044 gclient.os.path.exists(gclient.os.path.join(self.root_dir, 'main', '.git')
1045 ).AndReturn(False)
1046 gclient.os.path.exists(gclient.os.path.join(self.root_dir, 'base', '.git')
1047 ).AndReturn(False)
1048 gclient.os.path.exists(gclient.os.path.join(self.root_dir, name, '.git')
1049 ).AndReturn(False)
1050 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn(
1051 gclient.gclient_scm.CreateSCM)
1052 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1053 gclient.gclient_utils.FileRead(
1054 gclient.os.path.join(self.root_dir, name, options.deps_file)
1055 ).AndReturn(deps_content)
1056
1057 # base gets updated.
1058 gclient.gclient_scm.CreateSCM(base_url, self.root_dir, 'base').AndReturn(
1059 gclient.gclient_scm.CreateSCM)
1060 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1061 gclient.gclient_utils.FileRead(
1062 gclient.os.path.join(self.root_dir, 'base', options.deps_file)
1063 ).AndReturn(base_deps_content)
1064
1065 # main gets updated.
1066 gclient.gclient_scm.CreateSCM(main_url, self.root_dir, 'main').AndReturn(
1067 gclient.gclient_scm.CreateSCM)
1068 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1069
1070 # Process is done and will write an .gclient_entries.
1071 gclient.os.path.exists(
1072 gclient.os.path.join(self.root_dir, options.entries_filename)
1073 ).AndReturn(False)
1074 gclient.gclient_utils.FileWrite(
1075 gclient.os.path.join(self.root_dir, options.entries_filename),
1076 mox.IgnoreArg())
1077
1078 self.mox.ReplayAll()
1079 client = self._gclient_gclient(self.root_dir, options)
1080 client.SetConfig(gclient_config)
1081 client.RunOnDeps('update', self.args)
1082
1083 def testFromImplTwo(self):
1084 base_url = 'svn://base@123'
1085 deps_content = (
1086 "deps = {\n"
1087 " 'base': '%s',\n"
1088 " 'main': From('base', 'src/main'),\n"
1089 "}\n" % base_url
1090 )
1091 main_url = 'svn://main@456'
1092 base_deps_content = (
1093 "deps = {\n"
1094 " 'src/main': '%s',\n"
1095 "}\n" % main_url
1096 )
1097 # Fake .gclient file.
1098 name = 'testFromImplTwo_solution_name'
1099 gclient_config = (
1100 "solutions = [ {\n"
1101 "'name': '%s',\n"
1102 "'url': '%s',\n"
1103 "'custom_deps': {},\n"
1104 "}, ]" % (name, self.url))
1105
1106 options = self.Options()
1107 gclient.os.path.exists(gclient.os.path.join(self.root_dir, 'main', '.git')
1108 ).AndReturn(False)
1109 gclient.os.path.exists(gclient.os.path.join(self.root_dir, 'base', '.git')
1110 ).AndReturn(False)
1111 gclient.os.path.exists(gclient.os.path.join(self.root_dir, name, '.git')
1112 ).AndReturn(False)
1113 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn(
1114 gclient.gclient_scm.CreateSCM)
1115 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1116 gclient.gclient_utils.FileRead(
1117 gclient.os.path.join(self.root_dir, name, options.deps_file)
1118 ).AndReturn(deps_content)
1119
1120 # base gets updated.
1121 gclient.gclient_scm.CreateSCM(base_url, self.root_dir, 'base').AndReturn(
1122 gclient.gclient_scm.CreateSCM)
1123 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1124 gclient.gclient_utils.FileRead(
1125 gclient.os.path.join(self.root_dir, 'base', options.deps_file)
1126 ).AndReturn(base_deps_content)
1127
1128 # main gets updated.
1129 gclient.gclient_scm.CreateSCM(main_url, self.root_dir, 'main').AndReturn(
1130 gclient.gclient_scm.CreateSCM)
1131 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1132
1133 # Process is done and will write an .gclient_entries.
1134 gclient.os.path.exists(
1135 gclient.os.path.join(self.root_dir, options.entries_filename)
1136 ).AndReturn(False)
1137 gclient.gclient_utils.FileWrite(
1138 gclient.os.path.join(self.root_dir, options.entries_filename),
1139 mox.IgnoreArg())
1140
1141 self.mox.ReplayAll()
1142 client = self._gclient_gclient(self.root_dir, options)
1143 client.SetConfig(gclient_config)
1144 client.RunOnDeps('update', self.args)
1145
1146 def testFromImplTwoRelatvie(self):
1147 base_url = 'svn://base@123'
1148 deps_content = (
1149 "deps = {\n"
1150 " 'base': '%s',\n"
1151 " 'main': From('base', 'src/main'),\n"
1152 "}\n" % base_url
1153 )
1154 main_url = '/relative@456'
1155 base_deps_content = (
1156 "deps = {\n"
1157 " 'src/main': '%s',\n"
1158 "}\n" % main_url
1159 )
1160 # Fake .gclient file.
1161 name = 'testFromImplTwo_solution_name'
1162 gclient_config = (
1163 "solutions = [ {\n"
1164 "'name': '%s',\n"
1165 "'url': '%s',\n"
1166 "'custom_deps': {},\n"
1167 "}, ]" % (name, self.url))
1168
1169 options = self.Options()
1170 gclient.os.path.exists(gclient.os.path.join(self.root_dir, 'main', '.git')
1171 ).AndReturn(False)
1172 gclient.os.path.exists(gclient.os.path.join(self.root_dir, 'base', '.git')
1173 ).AndReturn(False)
1174 gclient.os.path.exists(gclient.os.path.join(self.root_dir, name, '.git')
1175 ).AndReturn(False)
1176 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn(
1177 gclient.gclient_scm.CreateSCM)
1178 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1179 gclient.gclient_utils.FileRead(
1180 gclient.os.path.join(self.root_dir, name, options.deps_file)
1181 ).AndReturn(deps_content)
1182
1183 # base gets updated.
1184 gclient.gclient_scm.CreateSCM(base_url, self.root_dir, 'base').AndReturn(
1185 gclient.gclient_scm.CreateSCM)
1186 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1187 gclient.gclient_utils.FileRead(
1188 gclient.os.path.join(self.root_dir, 'base', options.deps_file)
1189 ).AndReturn(base_deps_content)
1190
1191 # main gets updated after resolving the relative url.
1192 gclient.gclient_scm.CreateSCM(base_url, self.root_dir, None).AndReturn(
1193 gclient.gclient_scm.CreateSCM)
1194 gclient.gclient_scm.CreateSCM.FullUrlForRelativeUrl(main_url
1195 ).AndReturn('svn://base' + main_url)
1196 gclient.gclient_scm.CreateSCM('svn://base' + main_url, self.root_dir,
1197 'main').AndReturn(gclient.gclient_scm.CreateSCM)
1198 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1199
1200 # Process is done and will write an .gclient_entries.
1201 gclient.os.path.exists(
1202 gclient.os.path.join(self.root_dir, options.entries_filename)
1203 ).AndReturn(False)
1204 gclient.gclient_utils.FileWrite(
1205 gclient.os.path.join(self.root_dir, options.entries_filename),
1206 mox.IgnoreArg())
1207
1208 self.mox.ReplayAll()
1209 client = self._gclient_gclient(self.root_dir, options)
1210 client.SetConfig(gclient_config)
1211 client.RunOnDeps('update', self.args)
1023 1212
1024 def testFileImpl(self): 1213 def testFileImpl(self):
1025 # Fake .gclient file. 1214 # Fake .gclient file.
1026 name = "testFileImpl" 1215 name = "testFileImpl"
1027 gclient_config = ( 1216 gclient_config = (
1028 "solutions = [ { 'name': '%s'," 1217 "solutions = [ { 'name': '%s',"
1029 "'url': '%s', } ]" % (name, self.url) 1218 "'url': '%s', } ]" % (name, self.url)
1030 ) 1219 )
1031 # Fake DEPS file. 1220 # Fake DEPS file.
1032 target = "chromium_deps" 1221 target = "chromium_deps"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 pass 1270 pass
1082 def test_VarImpl(self): 1271 def test_VarImpl(self):
1083 pass 1272 pass
1084 1273
1085 1274
1086 if __name__ == '__main__': 1275 if __name__ == '__main__':
1087 import unittest 1276 import unittest
1088 unittest.main() 1277 unittest.main()
1089 1278
1090 # vim: ts=2:sw=2:tw=80:et: 1279 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « gclient.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698