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

Side by Side Diff: tests/fake_repos.py

Issue 2285002: Revert "Reapply 48271 with fix." (Closed)
Patch Set: Created 10 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
« no previous file with comments | « gclient.py ('k') | tests/gclient_smoketest.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 # 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 """Generate fake repositories for testing.""" 6 """Generate fake repositories for testing."""
7 7
8 import logging 8 import logging
9 import os 9 import os
10 import re 10 import re
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 fs[k] = fs[k] % { 'rev': rev } 198 fs[k] = fs[k] % { 'rev': rev }
199 fs['trunk/src/DEPS'] = DEPS 199 fs['trunk/src/DEPS'] = DEPS
200 return fs 200 return fs
201 201
202 # Testing: 202 # Testing:
203 # - dependency disapear 203 # - dependency disapear
204 # - dependency renamed 204 # - dependency renamed
205 # - versioned and unversioned reference 205 # - versioned and unversioned reference
206 # - relative and full reference 206 # - relative and full reference
207 # - deps_os 207 # - deps_os
208 # TODO(maruel):
208 # - var 209 # - var
209 # - hooks 210 # - hooks
210 # TODO(maruel):
211 # - File 211 # - File
212 # - $matching_files
213 # - use_relative_paths
214 self._commit_svn(file_system(1, """ 212 self._commit_svn(file_system(1, """
215 vars = {
216 'DummyVariable': 'third_party',
217 }
218 deps = { 213 deps = {
219 'src/other': 'svn://%(host)s/svn/trunk/other', 214 'src/other': 'svn://%(host)s/svn/trunk/other',
220 'src/third_party/fpp': '/trunk/' + Var('DummyVariable') + '/foo', 215 'src/third_party/fpp': '/trunk/third_party/foo',
221 } 216 }
222 deps_os = { 217 deps_os = {
223 'mac': { 218 'mac': {
224 'src/third_party/prout': '/trunk/third_party/prout', 219 'src/third_party/prout': '/trunk/third_party/prout',
225 }, 220 },
226 }""" % { 'host': '127.0.0.1' })) 221 }""" % { 'host': '127.0.0.1' }))
227 222
228 self._commit_svn(file_system(2, """ 223 self._commit_svn(file_system(2, """
229 deps = { 224 deps = {
230 'src/other': 'svn://%(host)s/svn/trunk/other', 225 'src/other': 'svn://%(host)s/svn/trunk/other',
231 'src/third_party/foo': '/trunk/third_party/foo@1', 226 'src/third_party/foo': '/trunk/third_party/foo@1',
232 } 227 }
233 # I think this is wrong to have the hooks run from the base of the gclient
234 # checkout. It's maybe a bit too late to change that behavior.
235 hooks = [
236 {
237 'pattern': '.',
238 'action': ['python', '-c',
239 'open(\\'src/hooked1\\', \\'w\\').write(\\'hooked1\\')'],
240 },
241 {
242 # Should not be run.
243 'pattern': 'nonexistent',
244 'action': ['python', '-c',
245 'open(\\'src/hooked2\\', \\'w\\').write(\\'hooked2\\')'],
246 },
247 ]
248 """ % { 'host': '127.0.0.1' })) 228 """ % { 'host': '127.0.0.1' }))
249 229
250 def setUpGIT(self): 230 def setUpGIT(self):
251 """Creates git repositories and start the servers.""" 231 """Creates git repositories and start the servers."""
252 assert not self.gitdaemon 232 assert not self.gitdaemon
253 rmtree(self.git_root) 233 rmtree(self.git_root)
254 for repo in ['repo_%d' % r for r in range(1, 5)]: 234 for repo in ['repo_%d' % r for r in range(1, 5)]:
255 check_call(['git', 'init', '-q', join(self.git_root, repo)]) 235 check_call(['git', 'init', '-q', join(self.git_root, repo)])
256 self.git_hashes[repo] = [] 236 self.git_hashes[repo] = []
257 237
258 # Testing: 238 # Testing:
259 # - dependency disapear 239 # - dependency disapear
260 # - dependency renamed 240 # - dependency renamed
261 # - versioned and unversioned reference 241 # - versioned and unversioned reference
262 # - relative and full reference 242 # - relative and full reference
263 # - deps_os 243 # - deps_os
244 # TODO(maruel):
264 # - var 245 # - var
265 # - hooks 246 # - hooks
266 # TODO(maruel):
267 # - File 247 # - File
268 # - $matching_files
269 # - use_relative_paths
270 self._commit_git('repo_1', { 248 self._commit_git('repo_1', {
271 'DEPS': """ 249 'DEPS': """
272 vars = {
273 'DummyVariable': 'repo',
274 }
275 deps = { 250 deps = {
276 'src/repo2': 'git://%(host)s/git/repo_2', 251 'src/repo2': 'git://%(host)s/git/repo_2',
277 'src/repo2/repo3': '/' + Var('DummyVariable') + '_3', 252 'src/repo2/repo3': '/repo_3',
278 } 253 }
279 deps_os = { 254 deps_os = {
280 'mac': { 255 'mac': {
281 'src/repo4': '/repo_4', 256 'src/repo4': '/repo_4',
282 }, 257 },
283 }""" % { 'host': '127.0.0.1' }, 258 }""" % { 'host': '127.0.0.1' },
284 'origin': 'git/repo_1@1\n', 259 'origin': 'git/repo_1@1\n',
285 }) 260 })
286 261
287 self._commit_git('repo_2', { 262 self._commit_git('repo_2', {
(...skipping 19 matching lines...) Expand all
307 self._commit_git('repo_4', { 282 self._commit_git('repo_4', {
308 'origin': "git/repo_4@2\n" 283 'origin': "git/repo_4@2\n"
309 }) 284 })
310 285
311 self._commit_git('repo_1', { 286 self._commit_git('repo_1', {
312 'DEPS': """ 287 'DEPS': """
313 deps = { 288 deps = {
314 'src/repo2': 'git://%(host)s/git/repo_2@%(hash)s', 289 'src/repo2': 'git://%(host)s/git/repo_2@%(hash)s',
315 'src/repo2/repo_renamed': '/repo_3', 290 'src/repo2/repo_renamed': '/repo_3',
316 } 291 }
317 # I think this is wrong to have the hooks run from the base of the gclient
318 # checkout. It's maybe a bit too late to change that behavior.
319 hooks = [
320 {
321 'pattern': '.',
322 'action': ['python', '-c',
323 'open(\\'src/hooked1\\', \\'w\\').write(\\'hooked1\\')'],
324 },
325 {
326 # Should not be run.
327 'pattern': 'nonexistent',
328 'action': ['python', '-c',
329 'open(\\'src/hooked2\\', \\'w\\').write(\\'hooked2\\')'],
330 },
331 ]
332 """ % { 'host': '127.0.0.1', 'hash': self.git_hashes['repo_2'][0][0] }, 292 """ % { 'host': '127.0.0.1', 'hash': self.git_hashes['repo_2'][0][0] },
333 'origin': "git/repo_1@2\n" 293 'origin': "git/repo_1@2\n"
334 }) 294 })
335 295
336 # Start the daemon. 296 # Start the daemon.
337 cmd = ['git', 'daemon', '--export-all', '--base-path=' + self.repos_dir] 297 cmd = ['git', 'daemon', '--export-all', '--base-path=' + self.repos_dir]
338 if self.local_only: 298 if self.local_only:
339 cmd.append('--listen=127.0.0.1') 299 cmd.append('--listen=127.0.0.1')
340 logging.debug(cmd) 300 logging.debug(cmd)
341 self.gitdaemon.append(Popen(cmd, cwd=self.repos_dir)) 301 self.gitdaemon.append(Popen(cmd, cwd=self.repos_dir))
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 sys.stdin.readline() 341 sys.stdin.readline()
382 except KeyboardInterrupt: 342 except KeyboardInterrupt:
383 fake.leak = True 343 fake.leak = True
384 finally: 344 finally:
385 fake.tearDown() 345 fake.tearDown()
386 return 0 346 return 0
387 347
388 348
389 if __name__ == '__main__': 349 if __name__ == '__main__':
390 sys.exit(main(sys.argv)) 350 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « gclient.py ('k') | tests/gclient_smoketest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698