OLD | NEW |
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 rev = re.search(r'revision (\d+).', out).group(1) | 82 rev = re.search(r'revision (\d+).', out).group(1) |
83 st = Popen(['svn', 'status'], cwd=repo).communicate()[0] | 83 st = Popen(['svn', 'status'], cwd=repo).communicate()[0] |
84 assert len(st) == 0, st | 84 assert len(st) == 0, st |
85 logging.debug('At revision %s' % rev) | 85 logging.debug('At revision %s' % rev) |
86 return rev | 86 return rev |
87 | 87 |
88 | 88 |
89 def commit_git(repo): | 89 def commit_git(repo): |
90 """Commits the changes and returns the new hash.""" | 90 """Commits the changes and returns the new hash.""" |
91 check_call(['git', 'add', '-A', '-f'], cwd=repo) | 91 check_call(['git', 'add', '-A', '-f'], cwd=repo) |
92 out = Popen(['git', 'commit', '-m', 'foo'], cwd=repo).communicate()[0] | 92 check_call(['git', 'commit', '-q', '--message', 'foo'], cwd=repo) |
93 rev = re.search(r'^\[.*? ([a-f\d]+)\] ', out).group(1) | 93 rev = Popen(['git', 'show-ref', '--head', 'HEAD'], |
| 94 cwd=repo).communicate()[0].split(' ', 1)[0] |
94 logging.debug('At revision %s' % rev) | 95 logging.debug('At revision %s' % rev) |
95 return rev | 96 return rev |
96 | 97 |
97 | 98 |
98 class FakeRepos(object): | 99 class FakeRepos(object): |
99 """Generate both svn and git repositories to test gclient functionality. | 100 """Generate both svn and git repositories to test gclient functionality. |
100 | 101 |
101 Many DEPS functionalities need to be tested: Var, File, From, deps_os, hooks, | 102 Many DEPS functionalities need to be tested: Var, File, From, deps_os, hooks, |
102 use_relative_paths. | 103 use_relative_paths. |
103 | 104 |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 sys.stdin.readline() | 384 sys.stdin.readline() |
384 except KeyboardInterrupt: | 385 except KeyboardInterrupt: |
385 fake.leak = True | 386 fake.leak = True |
386 finally: | 387 finally: |
387 fake.tearDown() | 388 fake.tearDown() |
388 return 0 | 389 return 0 |
389 | 390 |
390 | 391 |
391 if __name__ == '__main__': | 392 if __name__ == '__main__': |
392 sys.exit(main(sys.argv)) | 393 sys.exit(main(sys.argv)) |
OLD | NEW |