Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: testing_support/fake_repos.py

Issue 25322002: Add support in gclient for pre-DEPS hooks (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Revert "Add support in gclient for pre-DEPS hooks" Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gclient.py ('k') | tests/gclient_smoketest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 = 5 442 NB_GIT_REPOS = 4
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
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 disappear 562 # - dependency disapear
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
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
709 660
710 class FakeRepoTransitive(FakeReposBase): 661 class FakeRepoTransitive(FakeReposBase):
711 """Implements populateSvn()""" 662 """Implements populateSvn()"""
712 663
713 def populateSvn(self): 664 def populateSvn(self):
714 """Creates a few revisions of changes including a DEPS file.""" 665 """Creates a few revisions of changes including a DEPS file."""
715 # Repos 666 # Repos
716 subprocess2.check_call( 667 subprocess2.check_call(
717 ['svn', 'checkout', self.svn_base, self.svn_checkout, 668 ['svn', 'checkout', self.svn_base, self.svn_checkout,
718 '-q', '--non-interactive', '--no-auth-cache', 669 '-q', '--non-interactive', '--no-auth-cache',
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 fake.set_up_git() 804 fake.set_up_git()
854 print('Fake setup, press enter to quit or Ctrl-C to keep the checkouts.') 805 print('Fake setup, press enter to quit or Ctrl-C to keep the checkouts.')
855 sys.stdin.readline() 806 sys.stdin.readline()
856 except KeyboardInterrupt: 807 except KeyboardInterrupt:
857 trial_dir.TrialDir.SHOULD_LEAK.leak = True 808 trial_dir.TrialDir.SHOULD_LEAK.leak = True
858 return 0 809 return 0
859 810
860 811
861 if __name__ == '__main__': 812 if __name__ == '__main__':
862 sys.exit(main(sys.argv)) 813 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « gclient.py ('k') | tests/gclient_smoketest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698