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 734 matching lines...) Loading... |
745 # parent timestamp on different repositories and the parent revision | 745 # parent timestamp on different repositories and the parent revision |
746 # otherwise. | 746 # otherwise. |
747 self._set_svn_commit_date('1', '2011-10-01T03:00:00.000000Z') | 747 self._set_svn_commit_date('1', '2011-10-01T03:00:00.000000Z') |
748 self._set_svn_commit_date('2', '2011-10-09T03:00:00.000000Z') | 748 self._set_svn_commit_date('2', '2011-10-09T03:00:00.000000Z') |
749 self._set_svn_commit_date('3', '2011-10-02T03:00:00.000000Z') | 749 self._set_svn_commit_date('3', '2011-10-02T03:00:00.000000Z') |
750 | 750 |
751 def populateGit(self): | 751 def populateGit(self): |
752 pass | 752 pass |
753 | 753 |
754 | 754 |
| 755 class FakeRepoSkiaDEPS(FakeReposBase): |
| 756 """Simulates the Skia DEPS transition in Chrome.""" |
| 757 |
| 758 NB_GIT_REPOS = 5 |
| 759 |
| 760 DEPS_svn_pre = """deps = { |
| 761 'src/third_party/skia/gyp': '%(svn_base)sskia/gyp', |
| 762 'src/third_party/skia/include': '%(svn_base)sskia/include', |
| 763 'src/third_party/skia/src': '%(svn_base)sskia/src', |
| 764 }""" |
| 765 |
| 766 DEPS_git_pre = """deps = { |
| 767 'src/third_party/skia/gyp': '%(git_base)srepo_3', |
| 768 'src/third_party/skia/include': '%(git_base)srepo_4', |
| 769 'src/third_party/skia/src': '%(git_base)srepo_5', |
| 770 }""" |
| 771 |
| 772 DEPS_post = """deps = { |
| 773 'src/third_party/skia': '%(git_base)srepo_1', |
| 774 }""" |
| 775 |
| 776 def populateSvn(self): |
| 777 """Create revisions which simulate the Skia DEPS transition in Chrome.""" |
| 778 subprocess2.check_call( |
| 779 ['svn', 'checkout', self.svn_base, self.svn_checkout, |
| 780 '-q', '--non-interactive', '--no-auth-cache', |
| 781 '--username', self.USERS[0][0], '--password', self.USERS[0][1]]) |
| 782 assert os.path.isdir(join(self.svn_checkout, '.svn')) |
| 783 |
| 784 # Skia repo. |
| 785 self._commit_svn({ |
| 786 'skia/skia_base_file': 'root-level file.', |
| 787 'skia/gyp/gyp_file': 'file in the gyp directory', |
| 788 'skia/include/include_file': 'file in the include directory', |
| 789 'skia/src/src_file': 'file in the src directory', |
| 790 }) |
| 791 |
| 792 # Chrome repo. |
| 793 self._commit_svn({ |
| 794 'trunk/src/DEPS': self.DEPS_svn_pre % {'svn_base': self.svn_base}, |
| 795 'trunk/src/myfile': 'svn/trunk/src@1' |
| 796 }) |
| 797 self._commit_svn({ |
| 798 'trunk/src/DEPS': self.DEPS_post % {'git_base': self.git_base}, |
| 799 'trunk/src/myfile': 'svn/trunk/src@2' |
| 800 }) |
| 801 |
| 802 def populateGit(self): |
| 803 # Skia repo. |
| 804 self._commit_git('repo_1', { |
| 805 'skia_base_file': 'root-level file.', |
| 806 'gyp/gyp_file': 'file in the gyp directory', |
| 807 'include/include_file': 'file in the include directory', |
| 808 'src/src_file': 'file in the src directory', |
| 809 }) |
| 810 self._commit_git('repo_3', { # skia/gyp |
| 811 'gyp_file': 'file in the gyp directory', |
| 812 }) |
| 813 self._commit_git('repo_4', { # skia/include |
| 814 'include_file': 'file in the include directory', |
| 815 }) |
| 816 self._commit_git('repo_5', { # skia/src |
| 817 'src_file': 'file in the src directory', |
| 818 }) |
| 819 |
| 820 # Chrome repo. |
| 821 self._commit_git('repo_2', { |
| 822 'DEPS': self.DEPS_git_pre % {'git_base': self.git_base}, |
| 823 'myfile': 'svn/trunk/src@1' |
| 824 }) |
| 825 self._commit_git('repo_2', { |
| 826 'DEPS': self.DEPS_post % {'git_base': self.git_base}, |
| 827 'myfile': 'svn/trunk/src@2' |
| 828 }) |
| 829 |
| 830 |
755 class FakeReposTestBase(trial_dir.TestCase): | 831 class FakeReposTestBase(trial_dir.TestCase): |
756 """This is vaguely inspired by twisted.""" | 832 """This is vaguely inspired by twisted.""" |
757 # Static FakeRepos instances. Lazy loaded. | 833 # Static FakeRepos instances. Lazy loaded. |
758 CACHED_FAKE_REPOS = {} | 834 CACHED_FAKE_REPOS = {} |
759 # Override if necessary. | 835 # Override if necessary. |
760 FAKE_REPOS_CLASS = FakeRepos | 836 FAKE_REPOS_CLASS = FakeRepos |
761 | 837 |
762 def setUp(self): | 838 def setUp(self): |
763 super(FakeReposTestBase, self).setUp() | 839 super(FakeReposTestBase, self).setUp() |
764 if not self.FAKE_REPOS_CLASS in self.CACHED_FAKE_REPOS: | 840 if not self.FAKE_REPOS_CLASS in self.CACHED_FAKE_REPOS: |
(...skipping 88 matching lines...) Loading... |
853 fake.set_up_git() | 929 fake.set_up_git() |
854 print('Fake setup, press enter to quit or Ctrl-C to keep the checkouts.') | 930 print('Fake setup, press enter to quit or Ctrl-C to keep the checkouts.') |
855 sys.stdin.readline() | 931 sys.stdin.readline() |
856 except KeyboardInterrupt: | 932 except KeyboardInterrupt: |
857 trial_dir.TrialDir.SHOULD_LEAK.leak = True | 933 trial_dir.TrialDir.SHOULD_LEAK.leak = True |
858 return 0 | 934 return 0 |
859 | 935 |
860 | 936 |
861 if __name__ == '__main__': | 937 if __name__ == '__main__': |
862 sys.exit(main(sys.argv)) | 938 sys.exit(main(sys.argv)) |
OLD | NEW |