| 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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 432 |
| 433 def populateSvn(self): | 433 def populateSvn(self): |
| 434 raise NotImplementedError() | 434 raise NotImplementedError() |
| 435 | 435 |
| 436 def populateGit(self): | 436 def populateGit(self): |
| 437 raise NotImplementedError() | 437 raise NotImplementedError() |
| 438 | 438 |
| 439 | 439 |
| 440 class FakeRepos(FakeReposBase): | 440 class FakeRepos(FakeReposBase): |
| 441 """Implements populateSvn() and populateGit().""" | 441 """Implements populateSvn() and populateGit().""" |
| 442 NB_GIT_REPOS = 4 | 442 NB_GIT_REPOS = 5 |
| 443 | 443 |
| 444 def populateSvn(self): | 444 def populateSvn(self): |
| 445 """Creates a few revisions of changes including DEPS files.""" | 445 """Creates a few revisions of changes including DEPS files.""" |
| 446 # Repos | 446 # Repos |
| 447 subprocess2.check_call( | 447 subprocess2.check_call( |
| 448 ['svn', 'checkout', self.svn_base, self.svn_checkout, | 448 ['svn', 'checkout', self.svn_base, self.svn_checkout, |
| 449 '-q', '--non-interactive', '--no-auth-cache', | 449 '-q', '--non-interactive', '--no-auth-cache', |
| 450 '--username', self.USERS[0][0], '--password', self.USERS[0][1]]) | 450 '--username', self.USERS[0][0], '--password', self.USERS[0][1]]) |
| 451 assert os.path.isdir(join(self.svn_checkout, '.svn')) | 451 assert os.path.isdir(join(self.svn_checkout, '.svn')) |
| 452 def file_system(rev, DEPS, DEPS_ALT=None): | 452 def file_system(rev, DEPS, DEPS_ALT=None): |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 { | 552 { |
| 553 'pattern': '.*', | 553 'pattern': '.*', |
| 554 'action': ['echo', 'foo'], | 554 'action': ['echo', 'foo'], |
| 555 }, | 555 }, |
| 556 ] | 556 ] |
| 557 """ % { 'svn_base': self.svn_base } | 557 """ % { 'svn_base': self.svn_base } |
| 558 self._commit_svn(fs) | 558 self._commit_svn(fs) |
| 559 | 559 |
| 560 def populateGit(self): | 560 def populateGit(self): |
| 561 # Testing: | 561 # Testing: |
| 562 # - dependency disapear | 562 # - dependency disappear |
| 563 # - dependency renamed | 563 # - dependency renamed |
| 564 # - versioned and unversioned reference | 564 # - versioned and unversioned reference |
| 565 # - relative and full reference | 565 # - relative and full reference |
| 566 # - deps_os | 566 # - deps_os |
| 567 # - var | 567 # - var |
| 568 # - hooks | 568 # - hooks |
| 569 # - From | 569 # - From |
| 570 # TODO(maruel): | 570 # TODO(maruel): |
| 571 # - File: File is hard to test here because it's SVN-only. It's | 571 # - File: File is hard to test here because it's SVN-only. It's |
| 572 # implementation should probably be replaced to use urllib instead. | 572 # implementation should probably be replaced to use urllib instead. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 """ % { | 650 """ % { |
| 651 'git_base': self.git_base, | 651 'git_base': self.git_base, |
| 652 # See self.__init__() for the format. Grab's the hash of the first | 652 # See self.__init__() for the format. Grab's the hash of the first |
| 653 # commit in repo_2. Only keep the first 7 character because of: | 653 # commit in repo_2. Only keep the first 7 character because of: |
| 654 # TODO(maruel): http://crosbug.com/3591 We need to strip the hash.. duh. | 654 # TODO(maruel): http://crosbug.com/3591 We need to strip the hash.. duh. |
| 655 'hash': self.git_hashes['repo_2'][1][0][:7] | 655 'hash': self.git_hashes['repo_2'][1][0][:7] |
| 656 }, | 656 }, |
| 657 'origin': 'git/repo_1@2\n', | 657 'origin': 'git/repo_1@2\n', |
| 658 }) | 658 }) |
| 659 | 659 |
| 660 self._commit_git('repo_5', {'origin': 'git/repo_5@1\n'}) |
| 661 self._commit_git('repo_5', { |
| 662 'DEPS': """ |
| 663 deps = { |
| 664 'src/repo1': '%(git_base)srepo_1@%(hash1)s', |
| 665 'src/repo2': '%(git_base)srepo_2@%(hash2)s', |
| 666 } |
| 667 |
| 668 # Hooks to run after a project is processed but before its dependencies are |
| 669 # processed. |
| 670 pre_deps_hooks = [ |
| 671 { |
| 672 'action': ['python', '-c', |
| 673 'print "pre-deps hook"; open(\\'src/git_pre_deps_hooked\\', \\'w\
\').write(\\'git_pre_deps_hooked\\')'], |
| 674 } |
| 675 ] |
| 676 """ % { |
| 677 'git_base': self.git_base, |
| 678 'hash1': self.git_hashes['repo_1'][2][0][:7], |
| 679 'hash2': self.git_hashes['repo_2'][1][0][:7], |
| 680 }, |
| 681 'origin': 'git/repo_5@2\n', |
| 682 }) |
| 683 self._commit_git('repo_5', { |
| 684 'DEPS': """ |
| 685 deps = { |
| 686 'src/repo1': '%(git_base)srepo_1@%(hash1)s', |
| 687 'src/repo2': '%(git_base)srepo_2@%(hash2)s', |
| 688 } |
| 689 |
| 690 # Hooks to run after a project is processed but before its dependencies are |
| 691 # processed. |
| 692 pre_deps_hooks = [ |
| 693 { |
| 694 'action': ['python', '-c', |
| 695 'print "pre-deps hook"; open(\\'src/git_pre_deps_hooked\\', \\'w\
\').write(\\'git_pre_deps_hooked\\')'], |
| 696 }, |
| 697 { |
| 698 'action': ['python', '-c', 'import sys; sys.exit(1)'], |
| 699 } |
| 700 ] |
| 701 """ % { |
| 702 'git_base': self.git_base, |
| 703 'hash1': self.git_hashes['repo_1'][2][0][:7], |
| 704 'hash2': self.git_hashes['repo_2'][1][0][:7], |
| 705 }, |
| 706 'origin': 'git/repo_5@3\n', |
| 707 }) |
| 708 |
| 660 | 709 |
| 661 class FakeRepoTransitive(FakeReposBase): | 710 class FakeRepoTransitive(FakeReposBase): |
| 662 """Implements populateSvn()""" | 711 """Implements populateSvn()""" |
| 663 | 712 |
| 664 def populateSvn(self): | 713 def populateSvn(self): |
| 665 """Creates a few revisions of changes including a DEPS file.""" | 714 """Creates a few revisions of changes including a DEPS file.""" |
| 666 # Repos | 715 # Repos |
| 667 subprocess2.check_call( | 716 subprocess2.check_call( |
| 668 ['svn', 'checkout', self.svn_base, self.svn_checkout, | 717 ['svn', 'checkout', self.svn_base, self.svn_checkout, |
| 669 '-q', '--non-interactive', '--no-auth-cache', | 718 '-q', '--non-interactive', '--no-auth-cache', |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 fake.set_up_git() | 853 fake.set_up_git() |
| 805 print('Fake setup, press enter to quit or Ctrl-C to keep the checkouts.') | 854 print('Fake setup, press enter to quit or Ctrl-C to keep the checkouts.') |
| 806 sys.stdin.readline() | 855 sys.stdin.readline() |
| 807 except KeyboardInterrupt: | 856 except KeyboardInterrupt: |
| 808 trial_dir.TrialDir.SHOULD_LEAK.leak = True | 857 trial_dir.TrialDir.SHOULD_LEAK.leak = True |
| 809 return 0 | 858 return 0 |
| 810 | 859 |
| 811 | 860 |
| 812 if __name__ == '__main__': | 861 if __name__ == '__main__': |
| 813 sys.exit(main(sys.argv)) | 862 sys.exit(main(sys.argv)) |
| OLD | NEW |