Beispiel #1
0
import os
import types
import unittest
from contextlib import contextmanager
from textwrap import dedent
from unittest import skipIf

from pants.scm.git import Git
from pants.scm.scm import Scm
from pants.util.contextutil import environment_as, pushd, temporary_dir
from pants.util.dirutil import chmod_plus_x, safe_mkdir, safe_mkdtemp, safe_open, safe_rmtree, touch
from pants.util.process_handler import subprocess
from pants_test.testutils.git_util import MIN_REQUIRED_GIT_VERSION, git_version


@skipIf(git_version() < MIN_REQUIRED_GIT_VERSION,
        'The GitTest requires git >= {}.'.format(MIN_REQUIRED_GIT_VERSION))
class GitTest(unittest.TestCase):

  @staticmethod
  def init_repo(remote_name, remote):
    # TODO (peiyu) clean this up, use `git_util.initialize_repo`.
    subprocess.check_call(['git', 'init'])
    subprocess.check_call(['git', 'config', 'user.email', '*****@*****.**'])
    subprocess.check_call(['git', 'config', 'user.name', 'Your Name'])
    subprocess.check_call(['git', 'remote', 'add', remote_name, remote])

  def setUp(self):
    self.origin = safe_mkdtemp()
    with pushd(self.origin):
      subprocess.check_call(['git', 'init', '--bare'])
Beispiel #2
0
                # Traverse one symlink.
                (Link("d.ln"), ReadLink),
                (Dir("a"), DirectoryListing),
                (Dir("a/b"), DirectoryListing),
            ],
        )


class PosixFSTest(unittest.TestCase, FSTestBase):
    @contextmanager
    def mk_project_tree(self, build_root_src):
        yield self.mk_fs_tree(build_root_src)


@unittest.skipIf(
    git_version() < MIN_REQUIRED_GIT_VERSION, "The GitTest requires git >= {}.".format(MIN_REQUIRED_GIT_VERSION)
)
class GitFSTest(unittest.TestCase, FSTestBase):
    @contextmanager
    def mk_project_tree(self, build_root_src):
        # Use mk_fs_tree only to feed the files for the git repo, not using its FileSystemProjectTree.
        worktree = self.mk_fs_tree(build_root_src).build_root
        with initialize_repo(worktree) as git_repo:
            yield ScmProjectTree(worktree, git_repo, "HEAD")

    @unittest.skip("https://github.com/pantsbuild/pants/issues/3281")
    def test_walk_recursive(self):
        super(GitFSTest, self).test_walk_recursive()

    @unittest.skip("https://github.com/pantsbuild/pants/issues/3281")
    def test_walk_recursive_all(self):