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

Side by Side Diff: tests/fake_repos.py

Issue 2265002: Reapply 48271 with fix (again) (Closed)
Patch Set: Another fix + more smoke tests Created 10 years, 6 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):
209 # - var 208 # - var
210 # - hooks 209 # - hooks
210 # TODO(maruel):
211 # - File 211 # - File
212 # - $matching_files
213 # - use_relative_paths
212 self._commit_svn(file_system(1, """ 214 self._commit_svn(file_system(1, """
215 vars = {
216 'DummyVariable': 'third_party',
217 }
213 deps = { 218 deps = {
214 'src/other': 'svn://%(host)s/svn/trunk/other', 219 'src/other': 'svn://%(host)s/svn/trunk/other',
215 'src/third_party/fpp': '/trunk/third_party/foo', 220 'src/third_party/fpp': '/trunk/' + Var('DummyVariable') + '/foo',
216 } 221 }
217 deps_os = { 222 deps_os = {
218 'mac': { 223 'mac': {
219 'src/third_party/prout': '/trunk/third_party/prout', 224 'src/third_party/prout': '/trunk/third_party/prout',
220 }, 225 },
221 }""" % { 'host': '127.0.0.1' })) 226 }""" % { 'host': '127.0.0.1' }))
222 227
223 self._commit_svn(file_system(2, """ 228 self._commit_svn(file_system(2, """
224 deps = { 229 deps = {
225 'src/other': 'svn://%(host)s/svn/trunk/other', 230 'src/other': 'svn://%(host)s/svn/trunk/other',
226 'src/third_party/foo': '/trunk/third_party/foo@1', 231 'src/third_party/foo': '/trunk/third_party/foo@1',
227 } 232 }
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 ]
228 """ % { 'host': '127.0.0.1' })) 248 """ % { 'host': '127.0.0.1' }))
229 249
230 def setUpGIT(self): 250 def setUpGIT(self):
231 """Creates git repositories and start the servers.""" 251 """Creates git repositories and start the servers."""
232 assert not self.gitdaemon 252 assert not self.gitdaemon
233 rmtree(self.git_root) 253 rmtree(self.git_root)
234 for repo in ['repo_%d' % r for r in range(1, 5)]: 254 for repo in ['repo_%d' % r for r in range(1, 5)]:
235 check_call(['git', 'init', '-q', join(self.git_root, repo)]) 255 check_call(['git', 'init', '-q', join(self.git_root, repo)])
236 self.git_hashes[repo] = [] 256 self.git_hashes[repo] = []
237 257
238 # Testing: 258 # Testing:
239 # - dependency disapear 259 # - dependency disapear
240 # - dependency renamed 260 # - dependency renamed
241 # - versioned and unversioned reference 261 # - versioned and unversioned reference
242 # - relative and full reference 262 # - relative and full reference
243 # - deps_os 263 # - deps_os
244 # TODO(maruel):
245 # - var 264 # - var
246 # - hooks 265 # - hooks
266 # TODO(maruel):
247 # - File 267 # - File
268 # - $matching_files
269 # - use_relative_paths
248 self._commit_git('repo_1', { 270 self._commit_git('repo_1', {
249 'DEPS': """ 271 'DEPS': """
272 vars = {
273 'DummyVariable': 'repo',
274 }
250 deps = { 275 deps = {
251 'src/repo2': 'git://%(host)s/git/repo_2', 276 'src/repo2': 'git://%(host)s/git/repo_2',
252 'src/repo2/repo3': '/repo_3', 277 'src/repo2/repo3': '/' + Var('DummyVariable') + '_3',
253 } 278 }
254 deps_os = { 279 deps_os = {
255 'mac': { 280 'mac': {
256 'src/repo4': '/repo_4', 281 'src/repo4': '/repo_4',
257 }, 282 },
258 }""" % { 'host': '127.0.0.1' }, 283 }""" % { 'host': '127.0.0.1' },
259 'origin': 'git/repo_1@1\n', 284 'origin': 'git/repo_1@1\n',
260 }) 285 })
261 286
262 self._commit_git('repo_2', { 287 self._commit_git('repo_2', {
(...skipping 19 matching lines...) Expand all
282 self._commit_git('repo_4', { 307 self._commit_git('repo_4', {
283 'origin': "git/repo_4@2\n" 308 'origin': "git/repo_4@2\n"
284 }) 309 })
285 310
286 self._commit_git('repo_1', { 311 self._commit_git('repo_1', {
287 'DEPS': """ 312 'DEPS': """
288 deps = { 313 deps = {
289 'src/repo2': 'git://%(host)s/git/repo_2@%(hash)s', 314 'src/repo2': 'git://%(host)s/git/repo_2@%(hash)s',
290 'src/repo2/repo_renamed': '/repo_3', 315 'src/repo2/repo_renamed': '/repo_3',
291 } 316 }
292 """ % { 'host': '127.0.0.1', 'hash': self.git_hashes['repo_2'][0][0] }, 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 """ % {
333 # TODO(maruel): http://crosbug.com/3591 We need to strip the hash.. duh.
334 'host': '127.0.0.1', 'hash': self.git_hashes['repo_2'][0][0][:7] },
293 'origin': "git/repo_1@2\n" 335 'origin': "git/repo_1@2\n"
294 }) 336 })
295 337
296 # Start the daemon. 338 # Start the daemon.
297 cmd = ['git', 'daemon', '--export-all', '--base-path=' + self.repos_dir] 339 cmd = ['git', 'daemon', '--export-all', '--base-path=' + self.repos_dir]
298 if self.local_only: 340 if self.local_only:
299 cmd.append('--listen=127.0.0.1') 341 cmd.append('--listen=127.0.0.1')
300 logging.debug(cmd) 342 logging.debug(cmd)
301 self.gitdaemon.append(Popen(cmd, cwd=self.repos_dir)) 343 self.gitdaemon.append(Popen(cmd, cwd=self.repos_dir))
302 344
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 sys.stdin.readline() 383 sys.stdin.readline()
342 except KeyboardInterrupt: 384 except KeyboardInterrupt:
343 fake.leak = True 385 fake.leak = True
344 finally: 386 finally:
345 fake.tearDown() 387 fake.tearDown()
346 return 0 388 return 0
347 389
348 390
349 if __name__ == '__main__': 391 if __name__ == '__main__':
350 sys.exit(main(sys.argv)) 392 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