| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 atexit | 8 import atexit |
| 9 import datetime | 9 import datetime |
| 10 import errno | 10 import errno |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 else: | 303 else: |
| 304 write(join(root, k), v) | 304 write(join(root, k), v) |
| 305 | 305 |
| 306 def set_up_svn(self): | 306 def set_up_svn(self): |
| 307 """Creates subversion repositories and start the servers.""" | 307 """Creates subversion repositories and start the servers.""" |
| 308 self.set_up() | 308 self.set_up() |
| 309 if self.svnserve: | 309 if self.svnserve: |
| 310 return True | 310 return True |
| 311 try: | 311 try: |
| 312 subprocess2.check_call(['svnadmin', 'create', self.svn_repo]) | 312 subprocess2.check_call(['svnadmin', 'create', self.svn_repo]) |
| 313 except subprocess2.CalledProcessError, e: | 313 except (OSError, subprocess2.CalledProcessError): |
| 314 logging.debug('Failed with : %s' % e) | |
| 315 return False | 314 return False |
| 316 write(join(self.svn_repo, 'conf', 'svnserve.conf'), | 315 write(join(self.svn_repo, 'conf', 'svnserve.conf'), |
| 317 '[general]\n' | 316 '[general]\n' |
| 318 'anon-access = read\n' | 317 'anon-access = read\n' |
| 319 'auth-access = write\n' | 318 'auth-access = write\n' |
| 320 'password-db = passwd\n') | 319 'password-db = passwd\n') |
| 321 text = '[users]\n' | 320 text = '[users]\n' |
| 322 text += ''.join('%s = %s\n' % (usr, pwd) for usr, pwd in self.USERS) | 321 text += ''.join('%s = %s\n' % (usr, pwd) for usr, pwd in self.USERS) |
| 323 write(join(self.svn_repo, 'conf', 'passwd'), text) | 322 write(join(self.svn_repo, 'conf', 'passwd'), text) |
| 324 | 323 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 345 self.svn_base = 'svn://%s:%d/svn/' % (self.host, self.svn_port) | 344 self.svn_base = 'svn://%s:%d/svn/' % (self.host, self.svn_port) |
| 346 self.populateSvn() | 345 self.populateSvn() |
| 347 self.svn_dirty = False | 346 self.svn_dirty = False |
| 348 return True | 347 return True |
| 349 | 348 |
| 350 def set_up_git(self): | 349 def set_up_git(self): |
| 351 """Creates git repositories and start the servers.""" | 350 """Creates git repositories and start the servers.""" |
| 352 self.set_up() | 351 self.set_up() |
| 353 if self.gitdaemon: | 352 if self.gitdaemon: |
| 354 return True | 353 return True |
| 355 if sys.platform == 'win32': | 354 assert self.git_pid_file == None |
| 355 try: |
| 356 subprocess2.check_output(['git', '--version']) |
| 357 except (OSError, subprocess2.CalledProcessError): |
| 356 return False | 358 return False |
| 357 assert self.git_pid_file == None | |
| 358 for repo in ['repo_%d' % r for r in range(1, self.NB_GIT_REPOS + 1)]: | 359 for repo in ['repo_%d' % r for r in range(1, self.NB_GIT_REPOS + 1)]: |
| 359 subprocess2.check_call(['git', 'init', '-q', join(self.git_root, repo)]) | 360 subprocess2.check_call(['git', 'init', '-q', join(self.git_root, repo)]) |
| 360 self.git_hashes[repo] = [None] | 361 self.git_hashes[repo] = [None] |
| 361 self.git_port = find_free_port(self.host, 20000) | 362 self.git_port = find_free_port(self.host, 20000) |
| 362 self.git_base = 'git://%s:%d/git/' % (self.host, self.git_port) | 363 self.git_base = 'git://%s:%d/git/' % (self.host, self.git_port) |
| 363 # Start the daemon. | 364 # Start the daemon. |
| 364 self.git_pid_file = tempfile.NamedTemporaryFile() | 365 self.git_pid_file = tempfile.NamedTemporaryFile() |
| 365 cmd = ['git', 'daemon', | 366 cmd = ['git', 'daemon', |
| 366 '--export-all', | 367 '--export-all', |
| 367 '--reuseaddr', | 368 '--reuseaddr', |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 fake.set_up_git() | 733 fake.set_up_git() |
| 733 print('Fake setup, press enter to quit or Ctrl-C to keep the checkouts.') | 734 print('Fake setup, press enter to quit or Ctrl-C to keep the checkouts.') |
| 734 sys.stdin.readline() | 735 sys.stdin.readline() |
| 735 except KeyboardInterrupt: | 736 except KeyboardInterrupt: |
| 736 trial_dir.TrialDir.SHOULD_LEAK.leak = True | 737 trial_dir.TrialDir.SHOULD_LEAK.leak = True |
| 737 return 0 | 738 return 0 |
| 738 | 739 |
| 739 | 740 |
| 740 if __name__ == '__main__': | 741 if __name__ == '__main__': |
| 741 sys.exit(main(sys.argv)) | 742 sys.exit(main(sys.argv)) |
| OLD | NEW |