Пример #1
0
    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__
    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__
Пример #3
0
    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', 'bzr', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens)

        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()
        wstool_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'M', 'bzr', 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- bzr: {local-name: clone, uri: ../remote, version: \"footag\"}")
        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', 'bzr', '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()
        wstool_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'x', 'bzr', 'footag', os.path.join(self.test_root_path, 'remote')], tokens)
    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__
Пример #5
0
    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)
    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)
    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__
Пример #8
0
    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)
Пример #9
0
    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__
Пример #10
0
 def test_gen_python_code_python3(self):
     # requires python3 to be installed, obviously
     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 = "python3 %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)
Пример #11
0
 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)
Пример #12
0
 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)
Пример #13
0
def modify_bzr_repo(clone_path):
    # make local modifications
    subprocess.check_call(["rm", "deleted-fs.txt"], cwd=clone_path)
    subprocess.check_call(["bzr", "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(["bzr", "add", "added.txt"], cwd=clone_path)
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)
Пример #15
0
    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)
Пример #16
0
    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)
Пример #17
0
    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)
    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)
Пример #19
0
    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)
    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', '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()
        rosws_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()
        rosws_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()
        rosws_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        self.assertEqual(['clone', 'x', 'svn', '1', self.svn_uri], tokens)
    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)
Пример #22
0
 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)
    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)
Пример #24
0
    def setUp(self):
        AbstractSCMTest.setUp(self)
        self.remote_path = os.path.join(self.test_root_path, "remote")
        os.makedirs(self.remote_path)

        # create a "remote" repo
        subprocess.check_call(["git", "init"], cwd=self.remote_path)
        subprocess.check_call(["touch", "test.txt"], cwd=self.remote_path)
        subprocess.check_call(["git", "add", "*"], cwd=self.remote_path)
        subprocess.check_call(["git", "commit", "-m", "modified"],
                              cwd=self.remote_path)
        po = subprocess.Popen(
            ["git", "log", "-n", "1", "--pretty=format:\"%H\""],
            cwd=self.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=self.remote_path)
        subprocess.check_call(["touch", "test2.txt"], cwd=self.remote_path)
        subprocess.check_call(["git", "add", "*"], cwd=self.remote_path)
        subprocess.check_call(["git", "commit", "-m", "modified"],
                              cwd=self.remote_path)
        po = subprocess.Popen(
            ["git", "log", "-n", "1", "--pretty=format:\"%H\""],
            cwd=self.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}"
        )
        self.clone_path = os.path.join(self.local_path, "clone")

        cmd = ["wstool", "update"]
        os.chdir(self.local_path)
        sys.stdout = output = StringIO()
        wstool_main(cmd)
        output = output.getvalue()
        sys.stdout = sys.__stdout__
Пример #25
0
    def setUpClass(self):
        AbstractSCMTest.setUpClass()
        remote_path = os.path.join(self.test_root_path, "remote")
        os.makedirs(remote_path)

        create_git_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- git: {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_git_repo(clone_path)
Пример #26
0
    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(
            "'")

        # wstool 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 = ["wstool", "update"]
        os.chdir(self.local_path)
        sys.stdout = output = StringIO()
        wstool_main(cmd)
        output = output.getvalue()
        sys.stdout = sys.__stdout__
Пример #27
0
    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)
Пример #28
0
    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()
        wstool_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        localname = os.path.join(os.path.dirname(self.local_path), 'foo')
        self.assertEqual([localname, 'x', 'git', '(footag)', self.remote_path],
                         tokens)
Пример #29
0
    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', '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)
Пример #30
0
    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()
        wstool_main(cmd)
        output = output.getvalue()
        tokens = _nth_line_split(-2, output)
        localname = os.path.join(os.path.dirname(self.local_path), 'foo')
        self.assertEqual([localname, 'x', 'git', '(footag)', self.remote_path], tokens)