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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
379 '--port=%d' % self.git_port] | 379 '--port=%d' % self.git_port] |
380 if self.host == '127.0.0.1': | 380 if self.host == '127.0.0.1': |
381 cmd.append('--listen=' + self.host) | 381 cmd.append('--listen=' + self.host) |
382 self.check_port_is_free(self.git_port) | 382 self.check_port_is_free(self.git_port) |
383 self.gitdaemon = subprocess2.Popen( | 383 self.gitdaemon = subprocess2.Popen( |
384 cmd, | 384 cmd, |
385 cwd=self.root_dir, | 385 cwd=self.root_dir, |
386 stdout=subprocess2.PIPE, | 386 stdout=subprocess2.PIPE, |
387 stderr=subprocess2.PIPE) | 387 stderr=subprocess2.PIPE) |
388 wait_for_port_to_bind(self.host, self.git_port, self.gitdaemon) | 388 wait_for_port_to_bind(self.host, self.git_port, self.gitdaemon) |
389 self.populateGit() | 389 self.populateGit() |
Primiano Tucci (use gerrit)
2015/02/09 21:32:04
Moving the git commits operations before starting
| |
390 self.git_dirty = False | 390 self.git_dirty = False |
391 return True | 391 return True |
392 | 392 |
393 def _commit_svn(self, tree): | 393 def _commit_svn(self, tree): |
394 self._genTree(self.svn_checkout, tree) | 394 self._genTree(self.svn_checkout, tree) |
395 commit_svn(self.svn_checkout, self.USERS[0][0], self.USERS[0][1]) | 395 commit_svn(self.svn_checkout, self.USERS[0][0], self.USERS[0][1]) |
396 if self.svn_revs and self.svn_revs[-1]: | 396 if self.svn_revs and self.svn_revs[-1]: |
397 new_tree = self.svn_revs[-1].copy() | 397 new_tree = self.svn_revs[-1].copy() |
398 new_tree.update(tree) | 398 new_tree.update(tree) |
399 else: | 399 else: |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
821 self._commit_git('repo_2', { | 821 self._commit_git('repo_2', { |
822 'DEPS': self.DEPS_git_pre % {'git_base': self.git_base}, | 822 'DEPS': self.DEPS_git_pre % {'git_base': self.git_base}, |
823 'myfile': 'svn/trunk/src@1' | 823 'myfile': 'svn/trunk/src@1' |
824 }) | 824 }) |
825 self._commit_git('repo_2', { | 825 self._commit_git('repo_2', { |
826 'DEPS': self.DEPS_post % {'git_base': self.git_base}, | 826 'DEPS': self.DEPS_post % {'git_base': self.git_base}, |
827 'myfile': 'svn/trunk/src@2' | 827 'myfile': 'svn/trunk/src@2' |
828 }) | 828 }) |
829 | 829 |
830 | 830 |
831 class FakeRepoBlinkDEPS(FakeReposBase): | |
832 """Simulates the Blink DEPS transition in Chrome.""" | |
833 | |
834 NB_GIT_REPOS = 2 | |
835 DEPS_pre = 'deps = {"src/third_party/WebKit": "%(git_base)srepo_2",}' | |
836 DEPS_post = 'deps = {}' | |
837 | |
838 def populateGit(self): | |
839 # Blink repo. | |
840 self._commit_git('repo_2', { | |
841 'OWNERS': 'OWNERS-pre', | |
842 'Source/exists_always': '_ignored_', | |
843 'Source/exists_before_but_not_after': '_ignored_', | |
844 }) | |
845 | |
846 # Chrome repo. | |
847 self._commit_git('repo_1', { | |
848 'DEPS': self.DEPS_pre % {'git_base': self.git_base}, | |
849 'myfile': 'myfile@1', | |
850 '.gitignore': '/third_party/WebKit', | |
851 }) | |
852 self._commit_git('repo_1', { | |
853 'DEPS': self.DEPS_post % {'git_base': self.git_base}, | |
854 'myfile': 'myfile@2', | |
855 '.gitignore': '', | |
856 'third_party/WebKit/OWNERS': 'OWNERS-post', | |
857 'third_party/WebKit/Source/exists_always': '_ignored_', | |
858 'third_party/WebKit/Source/exists_after_but_not_before': '_ignored', | |
859 }) | |
860 | |
861 def populateSvn(self): | |
862 raise NotImplementedError() | |
863 | |
864 | |
831 class FakeReposTestBase(trial_dir.TestCase): | 865 class FakeReposTestBase(trial_dir.TestCase): |
832 """This is vaguely inspired by twisted.""" | 866 """This is vaguely inspired by twisted.""" |
833 # Static FakeRepos instances. Lazy loaded. | 867 # Static FakeRepos instances. Lazy loaded. |
834 CACHED_FAKE_REPOS = {} | 868 CACHED_FAKE_REPOS = {} |
835 # Override if necessary. | 869 # Override if necessary. |
836 FAKE_REPOS_CLASS = FakeRepos | 870 FAKE_REPOS_CLASS = FakeRepos |
837 | 871 |
838 def setUp(self): | 872 def setUp(self): |
839 super(FakeReposTestBase, self).setUp() | 873 super(FakeReposTestBase, self).setUp() |
840 if not self.FAKE_REPOS_CLASS in self.CACHED_FAKE_REPOS: | 874 if not self.FAKE_REPOS_CLASS in self.CACHED_FAKE_REPOS: |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
929 fake.set_up_git() | 963 fake.set_up_git() |
930 print('Fake setup, press enter to quit or Ctrl-C to keep the checkouts.') | 964 print('Fake setup, press enter to quit or Ctrl-C to keep the checkouts.') |
931 sys.stdin.readline() | 965 sys.stdin.readline() |
932 except KeyboardInterrupt: | 966 except KeyboardInterrupt: |
933 trial_dir.TrialDir.SHOULD_LEAK.leak = True | 967 trial_dir.TrialDir.SHOULD_LEAK.leak = True |
934 return 0 | 968 return 0 |
935 | 969 |
936 | 970 |
937 if __name__ == '__main__': | 971 if __name__ == '__main__': |
938 sys.exit(main(sys.argv)) | 972 sys.exit(main(sys.argv)) |
OLD | NEW |