• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python scm_test_base._add_to_file函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中test.scm_test_base._add_to_file函数的典型用法代码示例。如果您正苦于以下问题:Python _add_to_file函数的具体用法?Python _add_to_file怎么用?Python _add_to_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了_add_to_file函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setUp

    def setUp(self):
        AbstractSCMTest.setUp(self)
        remote_path = os.path.join(self.test_root_path, "remote")
        os.makedirs(remote_path)

        # create a "remote" repo
        subprocess.check_call(["hg", "init"], cwd=remote_path)
        subprocess.check_call(["touch", "test.txt"], cwd=remote_path)
        subprocess.check_call(["hg", "add", "test.txt"], cwd=remote_path)
        subprocess.check_call(["hg", "commit", "-m", "modified"], cwd=remote_path)
        po = subprocess.Popen(["hg", "log", "--template", "'{node|short}'", "-l1"], cwd=remote_path, stdout=subprocess.PIPE)
        self.version_init = po.stdout.read().decode('UTF-8').rstrip("'").lstrip("'")
        subprocess.check_call(["hg", "tag", "footag"], cwd=remote_path)
        subprocess.check_call(["touch", "test2.txt"], cwd=remote_path)
        subprocess.check_call(["hg", "add", "test2.txt"], cwd=remote_path)
        subprocess.check_call(["hg", "commit", "-m", "modified"], cwd=remote_path)
        po = subprocess.Popen(["hg", "log", "--template", "'{node|short}'", "-l1"], cwd=remote_path, stdout=subprocess.PIPE)
        self.version_end = po.stdout.read().decode('UTF-8').rstrip("'").lstrip("'")

        # rosinstall the remote repo and fake ros
        _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- hg: {local-name: clone, uri: ../remote}")

        cmd = ["rosws", "update"]
        os.chdir(self.local_path)
        sys.stdout = output = StringIO()
        rosws_main(cmd)
        output = output.getvalue()
        sys.stdout = sys.__stdout__
开发者ID:eacousineau,项目名称:rosinstall,代码行数:28,代码来源:test_diff_functions_hg.py


示例2: setUpClass

    def setUpClass(self):
        AbstractSCMTest.setUpClass()
        self.remote_path = os.path.join(self.test_root_path, 'remote')
        self.new_remote_path = os.path.join(self.test_root_path, 'fooo')
        self.version = 'master'
        self.branch = 'test_branch'
        self.date = datetime.date.today().isoformat()
        os.makedirs(self.remote_path)

        create_git_repo(self.remote_path)

        # wstool the remote repo and fake ros
        entry = '''\
- other: {local-name: ../ros}
- git: {local-name: clone, uri: ../remote, version: %s}
''' % self.version
        _add_to_file(os.path.join(self.local_path, '.rosinstall'), entry)

        cmd = ['wstool', 'update', '-t', 'ws']
        os.chdir(self.test_root_path)
        wstool_main(cmd)

        self.clone_path = os.path.join(self.local_path, 'clone')

        modify_git_repo(self.clone_path)

        subprocess.check_call(['git', 'checkout', '-b', self.branch],
                              cwd=self.clone_path)
        subprocess.check_call(['git', 'remote', 'set-url', 'origin',
                               self.new_remote_path], cwd=self.clone_path)
开发者ID:cottsay,项目名称:wstool,代码行数:30,代码来源:test_export.py


示例3: test_rosinstall_detailed_locapath_info

    def test_rosinstall_detailed_locapath_info(self):
        cmd = ["rosws", "info", "-t", "ws"]
        os.chdir(self.test_root_path)
        sys.stdout = output = StringIO()
        rosws_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'hg', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens, output)

        clone_path = os.path.join(self.local_path, "clone")
        # make local modifications check
        subprocess.check_call(["hg", "rm", "test2.txt"], cwd=clone_path)
        os.chdir(self.test_root_path)
        sys.stdout = output = StringIO()
        rosws_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'M', 'hg', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens)

        subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path)
        _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- hg: {local-name: clone, uri: ../remote, version: \"footag\"}")
        os.chdir(self.test_root_path)
        sys.stdout = output = StringIO()
        rosws_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'MV', 'hg', 'footag', self.version_end, "(%s)" % self.version_init, os.path.join(self.test_root_path, 'remote')], tokens)

        subprocess.check_call(["rm", "-rf", "clone"], cwd=self.local_path)
        os.chdir(self.test_root_path)
        sys.stdout = output = StringIO()
        rosws_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'x', 'hg', 'footag', os.path.join(self.test_root_path, 'remote')], tokens)
开发者ID:eacousineau,项目名称:rosinstall,代码行数:35,代码来源:test_diff_functions_hg.py


示例4: setUp

    def setUp(self):
        AbstractSCMTest.setUp(self)
        remote_path = os.path.join(self.test_root_path, "remote")
        os.makedirs(remote_path)

        # create a "remote" repo
        subprocess.check_call(["git", "init"], cwd=remote_path)
        subprocess.check_call(["touch", "test.txt"], cwd=remote_path)
        subprocess.check_call(["git", "add", "*"], cwd=remote_path)
        subprocess.check_call(["git", "commit", "-m", "modified"], cwd=remote_path)
        po = subprocess.Popen(["git", "log", "-n", "1", "--pretty=format:\"%H\""], cwd=remote_path, stdout=subprocess.PIPE)
        self.version_init = po.stdout.read().decode('UTF-8').rstrip('"').lstrip('"')[0:12]
        subprocess.check_call(["git", "tag", "footag"], cwd=remote_path)
        subprocess.check_call(["touch", "test2.txt"], cwd=remote_path)
        subprocess.check_call(["git", "add", "*"], cwd=remote_path)
        subprocess.check_call(["git", "commit", "-m", "modified"], cwd=remote_path)
        po = subprocess.Popen(["git", "log", "-n", "1", "--pretty=format:\"%H\""], cwd=remote_path, stdout=subprocess.PIPE)
        self.version_end = po.stdout.read().decode('UTF-8').rstrip('"').lstrip('"')[0:12]

        # wstool the remote repo and fake ros
        _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: clone, uri: ../remote}")

        cmd = ["wstool", "update"]
        os.chdir(self.local_path)
        sys.stdout = output = StringIO()
        wstool_main(cmd)
        output = output.getvalue()
        sys.stdout = sys.__stdout__
开发者ID:NikolausDemmel,项目名称:wstool,代码行数:28,代码来源:test_diff_functions_git.py


示例5: setUp

    def setUp(self):
        AbstractSCMTest.setUp(self)
        remote_path = os.path.join(self.test_root_path, "remote")
        os.makedirs(remote_path)

        # create a "remote" repo
        subprocess.check_call(["bzr", "init"], cwd=remote_path)
        subprocess.check_call(["touch", "test.txt"], cwd=remote_path)
        subprocess.check_call(["bzr", "add", "test.txt"], cwd=remote_path)
        subprocess.check_call(["bzr", "commit", "-m", "modified"], cwd=remote_path)
        self.version_init = "1"
        subprocess.check_call(["bzr", "tag", "footag"], cwd=remote_path)
        subprocess.check_call(["touch", "test2.txt"], cwd=remote_path)
        subprocess.check_call(["bzr", "add", "test2.txt"], cwd=remote_path)
        subprocess.check_call(["bzr", "commit", "-m", "modified"], cwd=remote_path)
        self.version_end = "2"

        # rosinstall the remote repo and fake ros
        _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- bzr: {local-name: clone, uri: ../remote}")

        cmd = ["rosws", "update"]
        os.chdir(self.local_path)
        sys.stdout = output = StringIO()
        rosws_main(cmd)
        output = output.getvalue()
        sys.stdout = sys.__stdout__
开发者ID:eacousineau,项目名称:rosinstall,代码行数:26,代码来源:test_diff_functions_bzr.py


示例6: setUp

    def setUp(self):
        AbstractSCMTest.setUp(self)
        remote_path = os.path.join(self.test_root_path, "remote")
        filler_path = os.path.join(self.test_root_path, "filler")
        self.svn_uri = "file://localhost" + remote_path

        # create a "remote" repo
        subprocess.check_call(["svnadmin", "create", remote_path], cwd=self.test_root_path)
        subprocess.check_call(["svn", "checkout", self.svn_uri, filler_path], cwd=self.test_root_path)
        subprocess.check_call(["touch", "test.txt"], cwd=filler_path)
        subprocess.check_call(["svn", "add", "test.txt"], cwd=filler_path)
        subprocess.check_call(["svn", "commit", "-m", "modified"], cwd=filler_path)
        subprocess.check_call(["touch", "test2.txt"], cwd=filler_path)
        subprocess.check_call(["svn", "add", "test2.txt"], cwd=filler_path)
        subprocess.check_call(["svn", "commit", "-m", "modified"], cwd=filler_path)

        self.version_init = "-r1"
        self.version_end = "-r2"

        # wstool the remote repo and fake ros
        _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- svn: {local-name: clone, uri: '" + self.svn_uri + "'}")

        cmd = ["wstool", "update"]
        os.chdir(self.local_path)
        sys.stdout = output = StringIO()
        wstool_main(cmd)
        output = output.getvalue()
        sys.stdout = sys.__stdout__
开发者ID:jpgr87,项目名称:wstool,代码行数:28,代码来源:test_diff_functions_svn.py


示例7: setUpClass

 def setUpClass(self):
     self.environback = copy.copy(os.environ)
     self.new_environ = os.environ
     self.test_root_path = tempfile.mkdtemp()
     self.install_path = os.path.join(self.test_root_path, "install")
     os.makedirs(self.install_path)
     self.install_path2 = os.path.join(self.test_root_path, "install2")
     os.makedirs(self.install_path2)
     _add_to_file(os.path.join(self.install_path, "configfile"), 'content')
     path = self.install_path
     for i in range(4):
         path = os.path.join(path, "path%s" % i)
         os.makedirs(path)
开发者ID:jamuraa,项目名称:rosinstall,代码行数:13,代码来源:test_cli.py


示例8: modify_hg_repo

def modify_hg_repo(clone_path):
    # make local modifications
    subprocess.check_call(["rm", "deleted-fs.txt"], cwd=clone_path)
    subprocess.check_call(["hg", "rm", "deleted.txt"], cwd=clone_path)
    _add_to_file(os.path.join(clone_path, "modified-fs.txt"), "foo\n")
    _add_to_file(os.path.join(clone_path, "modified.txt"), "foo\n")
    _add_to_file(os.path.join(clone_path, "added-fs.txt"), "tada\n")
    _add_to_file(os.path.join(clone_path, "added.txt"), "flam\n")
    subprocess.check_call(["hg", "add", "added.txt"], cwd=clone_path)
开发者ID:eacousineau,项目名称:rosinstall,代码行数:9,代码来源:test_diff_functions_hg.py


示例9: setUpClass

    def setUpClass(self):
        AbstractSCMTest.setUpClass()
        remote_path = os.path.join(self.test_root_path, "remote")
        os.makedirs(remote_path)

        create_bzr_repo(remote_path)

        # wstool the remote repo and fake ros
        _add_to_file(os.path.join(self.local_path, ".rosinstall"),
                     "- other: {local-name: ../ros}\n- bzr: {local-name: clone, uri: %s}" % remote_path)
        cmd = ["wstool", "update", "-t", "ws"]
        os.chdir(self.test_root_path)
        wstool_main(cmd)

        clone_path = os.path.join(self.local_path, "clone")

        modify_bzr_repo(clone_path)
开发者ID:NikolausDemmel,项目名称:wstool,代码行数:17,代码来源:test_diff_functions_bzr.py


示例10: setUpClass

    def setUpClass(self):
        AbstractSCMTest.setUpClass()
        remote_path = os.path.join(self.test_root_path, "remote")
        os.makedirs(remote_path)

        create_hg_repo(remote_path)

        # rosinstall the remote repo and fake ros
        _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- hg: {local-name: clone, uri: ../remote}")

        cmd = ["rosinstall", "ws", "-n"]
        os.chdir(self.test_root_path)
        rosinstall_main(cmd)

        clone_path = os.path.join(self.local_path, "clone")

        modify_hg_repo(clone_path)
开发者ID:eacousineau,项目名称:rosinstall,代码行数:17,代码来源:test_diff_functions_hg.py


示例11: setUpClass

    def setUpClass(self):
        AbstractSCMTest.setUpClass()
        remote_path = os.path.join(self.test_root_path, "remote")
        os.makedirs(remote_path)

        create_git_repo(remote_path)

        self.rosinstall_filename = os.path.join(self.local_path, "shallow-test.rosinstall")
        _add_to_file(self.rosinstall_filename, "- git: {local-name: clone, uri: \"file://" + remote_path + "\"}")

        cmd = ["wstool", "init", "ws-without-shallow", self.rosinstall_filename]
        os.chdir(self.test_root_path)
        wstool_main(cmd)

        cmd = ["wstool", "init", "--shallow", "ws-with-shallow", self.rosinstall_filename]
        os.chdir(self.test_root_path)
        wstool_main(cmd)
开发者ID:cottsay,项目名称:wstool,代码行数:17,代码来源:test_shallow_checkout_git.py


示例12: setUpClass

    def setUpClass(self):
        AbstractSCMTest.setUpClass()
        remote_path = os.path.join(self.test_root_path, "remote")
        filler_path = os.path.join(self.test_root_path, "filler")

        svn_uri = "file://localhost" + remote_path

        create_svn_repo(self.test_root_path, remote_path, filler_path, svn_uri)

        # wstool the remote repo and fake ros
        _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- svn: {local-name: clone, uri: '" + svn_uri + "'}")

        cmd = ["wstool", "update", "-t", "ws"]
        os.chdir(self.test_root_path)
        wstool_main(cmd)
        clone_path = os.path.join(self.local_path, "clone")

        modify_svn_repo(clone_path)
开发者ID:jpgr87,项目名称:wstool,代码行数:18,代码来源:test_diff_functions_svn.py


示例13: setUpClass

    def setUpClass(self):
        AbstractSCMTest.setUpClass()
        remote_path_svn = os.path.join(self.test_root_path, "remote_svn")
        remote_path_git = os.path.join(self.test_root_path, "remote_git")
        remote_path_bzr = os.path.join(self.test_root_path, "remote_bzr")
        remote_path_hg = os.path.join(self.test_root_path, "remote_hg")
        os.makedirs(remote_path_git)
        os.makedirs(remote_path_svn)
        os.makedirs(remote_path_hg)
        os.makedirs(remote_path_bzr)

        filler_path = os.path.join(self.test_root_path, "filler")
        svn_uri = "file://localhost"+remote_path_svn

        create_svn_repo(self.test_root_path, remote_path_svn, filler_path, svn_uri)
        create_git_repo(remote_path_git)
        create_hg_repo(remote_path_hg)
        create_bzr_repo(remote_path_bzr)

        # rosinstall the remote repo and fake ros (using git twice to check all overlaps)
        rosinstall_spec = """- other: {local-name: ../ros}
- git: {local-name: clone_git, uri: ../remote_git}
- svn: {local-name: clone_svn, uri: '%s'}
- hg: {local-name: clone_hg, uri: ../remote_hg}
- bzr: {local-name: clone_bzr, uri: ../remote_bzr}
- git: {local-name: clone_git2, uri: ../remote_git}""" % svn_uri

        _add_to_file(os.path.join(self.local_path, ".rosinstall"), rosinstall_spec)

        cmd = ["rosinstall", "ws", "-n"]
        os.chdir(self.test_root_path)
        rosinstall_main(cmd)

        clone_path_git = os.path.join(self.local_path, "clone_git")
        clone_path_git2 = os.path.join(self.local_path, "clone_git2")
        clone_path_svn = os.path.join(self.local_path, "clone_svn")
        clone_path_hg = os.path.join(self.local_path, "clone_hg")
        clone_path_bzr = os.path.join(self.local_path, "clone_bzr")

        modify_git_repo(clone_path_git2)
        modify_git_repo(clone_path_git)
        modify_svn_repo(clone_path_svn)
        modify_hg_repo(clone_path_hg)
        modify_bzr_repo(clone_path_bzr)
开发者ID:eacousineau,项目名称:rosinstall,代码行数:44,代码来源:test_diff_functions_multi.py


示例14: test_gen_python_code

 def test_gen_python_code(self):
     config = Config([PathSpec(os.path.join("test", "example_dirs", "ros_comm")),
                      PathSpec("bar.sh", tags=['setup-file']),
                      PathSpec("baz")],
                     self.directory,
                     None)
     rosinstall.config_yaml.generate_config_yaml(config, '.rosinstall', '')
     filename = os.path.join(self.directory, "test_gen.py")
     _add_to_file(filename, rosinstall.setupfiles.generate_embedded_python())
     sh_filename = os.path.join(self.directory, "bar.sh")
     _add_to_file(sh_filename, "#! /usr/bin/env sh")
     cmd = "python %s" % filename
     p = subprocess.Popen(cmd, shell=True, cwd=self.directory, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     output, err = p.communicate()
     self.assertEqual(''.encode('UTF-8'), err, err)
     self.assertTrue('/test/example_dirs/ros_comm'.encode('UTF-8') in output, output)
     self.assertTrue('baz'.encode('UTF-8') in output, output)
     self.assertTrue('ROSINSTALL_PATH_SETUPFILE_SEPARATOR'.encode('UTF-8') in output, output)
     self.assertTrue(output.endswith('/bar.sh\n'.encode('UTF-8')), output)
开发者ID:bteeter,项目名称:rosinstall,代码行数:19,代码来源:test_setupfiles.py


示例15: test_rosinstall_detailed_localpath_info

    def test_rosinstall_detailed_localpath_info(self):
        cmd = ["rosws", "info", "-t", "ws"]
        os.chdir(self.test_root_path)
        sys.stdout = output = StringIO()
        rosws_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'git', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens, output)

        clone_path = os.path.join(self.local_path, "clone")
        # make local modifications check
        subprocess.check_call(["rm", "test2.txt"], cwd=clone_path)
        sys.stdout = output = StringIO()
        rosws_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'M', 'git', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens)

        subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path)
        _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: clone, uri: ../remote, version: \"footag\"}")
        sys.stdout = output = StringIO()
        rosws_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'MV', 'git', 'footag', self.version_end, "(%s)" % self.version_init, os.path.join(self.test_root_path, 'remote')], tokens)

        # using a denormalized local-name here
        subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path)
        _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: clone/../clone, uri: ../remote, version: \"footag\"}")
        sys.stdout = output = StringIO()
        rosws_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'MV', 'git', 'footag', self.version_end, "(%s)" %
                         self.version_init, os.path.join(self.test_root_path, 'remote')], tokens)

        # using an absolute path to clone dir here
        subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path)
        _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: '"+clone_path+"', uri: ../remote, version: \"footag\"}")
        sys.stdout = output = StringIO()
        rosws_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual([clone_path, 'MV', 'git', 'footag', self.version_end, "(%s)" % self.version_init, os.path.join(self.test_root_path, 'remote')], tokens)

        # using an absolute path here where relative path is shorter to display (also checks x for missing)
        subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path)
        _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: '"+os.path.join(self.local_path, "../foo")+"', uri: ../remote, version: \"footag\"}")
        sys.stdout = output = StringIO()
        rosws_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
开发者ID:eacousineau,项目名称:rosinstall,代码行数:52,代码来源:test_diff_functions_git.py


示例16: test_rosinstall_detailed_locapath_info

    def test_rosinstall_detailed_locapath_info(self):
        cmd = ["wstool", "info", "-t", "ws"]
        os.chdir(self.test_root_path)
        sys.stdout = output = StringIO()
        wstool_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'svn', self.version_end, self.svn_uri], tokens)

        clone_path = os.path.join(self.local_path, "clone")
        # make local modifications check
        subprocess.check_call(["touch", "test3.txt"], cwd=clone_path)
        subprocess.check_call(["svn", "add", "test3.txt"], cwd=clone_path)
        os.chdir(self.test_root_path)
        sys.stdout = output = StringIO()
        wstool_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'M', 'svn', self.version_end, self.svn_uri], tokens)

        subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path)
        _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- svn: {local-name: clone, uri: '" + self.svn_uri + "', version: \"1\"}")
        os.chdir(self.test_root_path)
        sys.stdout = output = StringIO()
        wstool_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'MV', 'svn', '1', '(-)', self.version_end, "(%s)" % self.version_init, self.svn_uri], tokens)

        subprocess.check_call(["rm", "-rf", "clone"], cwd=self.local_path)
        os.chdir(self.test_root_path)
        sys.stdout = output = StringIO()
        wstool_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'x', 'svn', '(-)', self.svn_uri], tokens)
开发者ID:jpgr87,项目名称:wstool,代码行数:36,代码来源:test_diff_functions_svn.py


示例17: test_wstool_detailed_localpath_info

    def test_wstool_detailed_localpath_info(self):
        cmd = ["wstool", "info", "-t", "ws", "--managed-only"]
        os.chdir(self.test_root_path)
        sys.stdout = output = StringIO()
        wstool_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'git', 'master', '(-)', self.version_end, self.remote_path], tokens)

        # test when remote version is different
        subprocess.check_call(["git", "reset", "--hard", "HEAD~1"], cwd=self.clone_path)
        sys.stdout = output = StringIO()
        wstool_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'C', 'git', 'master', '(-)', self.version_init, self.remote_path], tokens)
        # return branch back to original revision
        subprocess.check_call(["git", "reset", "--hard", self.version_end], cwd=self.clone_path)

        # make local modifications check
        subprocess.check_call(["rm", "test2.txt"], cwd=self.clone_path)
        sys.stdout = output = StringIO()
        wstool_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'M', 'git', 'master', '(-)', self.version_end, self.remote_path], tokens)

        subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path)
        _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: clone, uri: ../remote, version: \"footag\"}")
        # test when version is different
        sys.stdout = output = StringIO()
        wstool_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'MV', 'git', 'master', '(footag)', self.version_end, "(%s)" % self.version_init, self.remote_path], tokens)
        # test when tracking branch is different from current branch
        subprocess.check_call(["git", "checkout", "-b", "test_branch"], cwd=self.clone_path)
        subprocess.check_call(["git", "config", "--replace-all", "branch.test_branch.remote", "origin"], cwd=self.clone_path)
        subprocess.check_call(["git", "config", "--replace-all", "branch.test_branch.merge", "master"], cwd=self.clone_path)
        sys.stdout = output = StringIO()
        wstool_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'MV', 'git', 'test_branch', '<', 'master', '(footag)', self.version_end, "(%s)" % self.version_init, self.remote_path], tokens)

        # test when remote is different from origin by rename
        subprocess.check_call(["git", "remote", "rename", "origin", "remote2"], cwd=self.clone_path)
        subprocess.check_call(["git", "config", "--replace-all", "branch.test_branch.remote", "remote2"], cwd=self.clone_path)
        sys.stdout = output = StringIO()
        wstool_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'MV', 'git', 'test_branch', '<', 'remote2/master', '(footag)', self.version_end, "(%s)" % self.version_init, "(%s)" % self.remote_path], tokens)
        # return remote name to origin
        subprocess.check_call(["git", "remote", "rename", "remote2", "origin"], cwd=self.clone_path)

        # test when remote is different from origin, no fetch
        subprocess.check_call(["git", "remote", "add", "remote2", "../../remote"], cwd=self.clone_path)
        subprocess.check_call(["git", "config", "--replace-all", "branch.test_branch.remote", "remote2"], cwd=self.clone_path)
        sys.stdout = output = StringIO()
        wstool_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'MV', 'git', 'test_branch', '(footag)', self.version_end, "(%s)" % self.version_init, self.remote_path], tokens)


        # test when remote is different from origin, with fetch
        sys.stdout = output = StringIO()
        wstool_main(cmd + ['--fetch'])
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'MV', 'git', 'test_branch', '<', 'remote2/master', '(footag)', self.version_end, "(%s)" % self.version_init, self.remote_path], tokens)


        # return branch back to master
        subprocess.check_call(["git", "checkout", "master"], cwd=self.clone_path)

        # using a denormalized local-name here
        subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path)
        _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: clone/../clone, uri: ../remote, version: \"footag\"}")
        sys.stdout = output = StringIO()
        wstool_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'MV', 'git', 'master', '(footag)', self.version_end, "(%s)" %
                         self.version_init, self.remote_path], tokens)

        # using an absolute path to clone dir here
        subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path)
        _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: '"+self.clone_path+"', uri: ../remote, version: \"footag\"}")
        sys.stdout = output = StringIO()
        wstool_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual([self.clone_path, 'MV', 'git', 'master', '(footag)', self.version_end, "(%s)" % self.version_init, self.remote_path], tokens)

        # using an absolute path here where relative path is shorter to display (also checks x for missing)
        subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path)
        _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: '"+os.path.join(self.local_path, "../foo")+"', uri: ../remote, version: \"footag\"}")
        sys.stdout = output = StringIO()
#.........这里部分代码省略.........
开发者ID:cbandera,项目名称:wstool,代码行数:101,代码来源:test_diff_functions_git.py



注:本文中的test.scm_test_base._add_to_file函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python script_helper.assert_python_failure函数代码示例发布时间:2022-05-27
下一篇:
Python runner.is_ptraceable函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap