def test_setup_sh(self): self.local_path = os.path.join(self.test_root_path, "ws13") cli = RoswsCLI() self.assertEqual( 0, cli.cmd_init([self.local_path, self.simple_rosinstall])) command = "echo $ROS_WORKSPACE" self.execute_check_result_allshells(command, self.local_path, expect=self.local_path) self.execute_check_result_allshells(command, '.', cwd=self.local_path, expect=self.local_path) self.execute_check_result_allshells(command, 'ws13', cwd=self.test_root_path, expect=self.local_path) local_ros_path = os.path.join(self.local_path, "ros") local_git_path = os.path.join(self.local_path, "gitrepo") package_path = "%s:%s" % (local_git_path, local_ros_path) command = "echo $ROS_PACKAGE_PATH" self.execute_check_result_allshells(command, self.local_path, expect=package_path) self.execute_check_result_allshells(command, '.', cwd=self.local_path, expect=package_path) self.execute_check_result_allshells(command, 'ws13', cwd=self.test_root_path, expect=package_path)
def test_Rosinstall_status_bzr_untracked(self): """Test status output for bzr when run outside workspace""" cmd = ["rosinstall", "ws", "--status-untracked"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() rosinstall_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.assertEqual( '? clone/added-fs.txt\n+N clone/added.txt\n D clone/deleted-fs.txt\n-D clone/deleted.txt\n M clone/modified-fs.txt\n M clone/modified.txt\n', output) cmd = ["rosws", "status", "-t", "ws", "--untracked"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() rosws_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.assertEqual( '? clone/added-fs.txt\n+N clone/added.txt\n D clone/deleted-fs.txt\n-D clone/deleted.txt\n M clone/modified-fs.txt\n M clone/modified.txt\n', output) cli = RoswsCLI() self.assertEqual( 0, cli.cmd_status(os.path.join(self.test_root_path, 'ws'), ["--untracked"]))
def gather_dependencies(path: str) -> None: """Gather all dependencies. This is equivalent to calling `rosws update` on the given workspace path. Internal use only. Args: path (str): Workspace path. """ path = os.path.abspath(path) # Workaround for dealing with local path with spaces. # Note: This is a slower alternative to `rosws`. if " " in path: import_.main(args=[ "--input", os.path.join(path, ".rosinstall"), "--shallow", "--debug", path, ]) else: cli = RoswsCLI() cli.cmd_update(path, ["-t", path])
def test_multi_status_untracked(self): '''tests status output for --untracked. In particular asserts that there are newlines between statuses, and no overlaps''' cmd = ["rosinstall", "ws", "--status-untracked"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() rosinstall_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.assertStatusListEqual( 'A clone_git/added.txt\n D clone_git/deleted-fs.txt\nD clone_git/deleted.txt\n M clone_git/modified-fs.txt\nM clone_git/modified.txt\n?? clone_git/added-fs.txt\n? clone_svn/added-fs.txt\nA clone_svn/added.txt\nD clone_svn/deleted.txt\n! clone_svn/deleted-fs.txt\nM clone_svn/modified.txt\nM clone_hg/modified-fs.txt\nM clone_hg/modified.txt\nA clone_hg/added.txt\nR clone_hg/deleted.txt\n! clone_hg/deleted-fs.txt\n? clone_hg/added-fs.txt\n? clone_bzr/added-fs.txt\n+N clone_bzr/added.txt\n D clone_bzr/deleted-fs.txt\n-D clone_bzr/deleted.txt\n M clone_bzr/modified-fs.txt\n M clone_bzr/modified.txt\nA clone_git2/added.txt\n D clone_git2/deleted-fs.txt\nD clone_git2/deleted.txt\n M clone_git2/modified-fs.txt\nM clone_git2/modified.txt\n?? clone_git2/added-fs.txt\n', output) cmd = ["rosws", "status", "-t", "ws", "--untracked"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() rosws_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.assertStatusListEqual( 'A clone_git/added.txt\n D clone_git/deleted-fs.txt\nD clone_git/deleted.txt\n M clone_git/modified-fs.txt\nM clone_git/modified.txt\n?? clone_git/added-fs.txt\n? clone_svn/added-fs.txt\nA clone_svn/added.txt\nD clone_svn/deleted.txt\n! clone_svn/deleted-fs.txt\nM clone_svn/modified.txt\nM clone_hg/modified-fs.txt\nM clone_hg/modified.txt\nA clone_hg/added.txt\nR clone_hg/deleted.txt\n! clone_hg/deleted-fs.txt\n? clone_hg/added-fs.txt\n? clone_bzr/added-fs.txt\n+N clone_bzr/added.txt\n D clone_bzr/deleted-fs.txt\n-D clone_bzr/deleted.txt\n M clone_bzr/modified-fs.txt\n M clone_bzr/modified.txt\nA clone_git2/added.txt\n D clone_git2/deleted-fs.txt\nD clone_git2/deleted.txt\n M clone_git2/modified-fs.txt\nM clone_git2/modified.txt\n?? clone_git2/added-fs.txt\n', output) cli = RoswsCLI() self.assertEqual( 0, cli.cmd_status(os.path.join(self.test_root_path, 'ws'), ["--untracked"]))
def test_Rosinstall_status_git_inside(self): """Test status output for git when run inside workspace""" directory = self.test_root_path + "/ws" cmd = ["rosinstall", ".", "--status"] os.chdir(directory) sys.stdout = output = StringIO() rosinstall_main(cmd) output = output.getvalue() self.assertEqual( 'A clone/added.txt\n D clone/deleted-fs.txt\nD clone/deleted.txt\n M clone/modified-fs.txt\nM clone/modified.txt\n', output) cmd = ["rosws", "status"] os.chdir(directory) sys.stdout = output = StringIO() rosws_main(cmd) output = output.getvalue() sys.stdout = sys.__stdout__ self.assertEqual( 'A clone/added.txt\n D clone/deleted-fs.txt\nD clone/deleted.txt\n M clone/modified-fs.txt\nM clone/modified.txt\n', output) cli = RoswsCLI() self.assertEqual(0, cli.cmd_diff(directory, []))
def test_cmd_init_makedir(self): # rosinstall to create dir self.local_path = os.path.join(self.test_root_path, "ws9") cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([self.local_path, self.ros_path])) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'setup.sh'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'setup.bash'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'setup.zsh')))
def test_init_pwd(self): workspace = os.path.join(self.test_root_path, 'ws1b') cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([workspace])) self.assertTrue(os.path.exists(workspace)) self.assertTrue(os.path.exists(os.path.join(workspace, '.rosinstall'))) self.assertTrue(os.path.exists(os.path.join(workspace, 'setup.sh'))) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') self.assertEqual(0, len(config.get_config_elements()))
def test_cmd_init_catkin2(self): self.local_path = os.path.join(self.test_root_path, "ws7") os.makedirs(self.local_path) cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([self.local_path, self.ros_path, "--catkin"])) self.assertFalse(os.path.exists(os.path.join(self.local_path, 'setup.sh'))) self.assertFalse(os.path.exists(os.path.join(self.local_path, 'setup.bash'))) self.assertFalse(os.path.exists(os.path.join(self.local_path, 'setup.zsh'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, '.rosinstall'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'CMakeLists.txt')))
def test_remove(self): workspace = os.path.join(self.test_root_path, 'ws3') cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([workspace, self.simple_rosinstall])) self.assertEqual(0, cli.cmd_merge(workspace, [self.simple_changed_vcs_rosinstall, '-y'])) self.assertEqual(0, cli.cmd_update(workspace, [])) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') self.assertEqual(3, len(config.get_config_elements())) self.assertEqual(0, cli.cmd_remove(workspace, ['hgrepo'])) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') self.assertEqual(2, len(config.get_config_elements()))
def test_rosws_info_svn(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', 'M', 'svn'], tokens[0:3]) cli = RoswsCLI() self.assertEqual(0, cli.cmd_info(os.path.join(self.test_root_path, 'ws'), []))
def test_cmd_init_makedir(self): # rosinstall to create dir self.local_path = os.path.join(self.test_root_path, "ws9") cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([self.local_path, self.ros_path])) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'setup.sh'))) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'setup.bash'))) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'setup.zsh')))
def test_rosws_info_hg(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', 'M', 'hg'], tokens[0:3], output) cli = RoswsCLI() self.assertEqual(0, cli.cmd_info(os.path.join(self.test_root_path, 'ws'), []))
def test_merge(self): workspace = os.path.join(self.test_root_path, 'ws2') cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([workspace, self.simple_rosinstall])) self.assertEqual(0, cli.cmd_merge(workspace, [self.simple_changed_vcs_rosinstall, '-y'])) self.assertFalse(os.path.isdir(os.path.join(workspace, 'hgrepo'))) self.assertFalse(os.path.isdir(os.path.join(workspace, 'hgrepo', '.hg'))) self.assertEqual(0, cli.cmd_update(workspace, [])) self.assertTrue(os.path.isdir(os.path.join(workspace, 'hgrepo'))) self.assertTrue(os.path.isdir(os.path.join(workspace, 'hgrepo', '.hg'))) config = wstool.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') self.assertEqual(3, len(config.get_config_elements()))
def test_cmd_generate_ros_files_build(self): self.local_path = os.path.join(self.test_root_path, "ws2b") os.makedirs(self.local_path) local_rosinstall = os.path.join(self.test_root_path, "local.rosinstall") _create_yaml_file([_create_config_elt_dict("git", 'ros_comm', self.git_path), _create_config_elt_dict("git", 'ros', self.ros_path), _create_config_elt_dict("hg", 'hgrepo', self.hg_path)], local_rosinstall) cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([self.local_path, local_rosinstall])) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'setup.sh'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'setup.bash'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'setup.zsh')))
def test_cmd_init_catkinpp(self): self.local_path = os.path.join(self.test_root_path, "ws8") os.makedirs(self.local_path) cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([self.local_path, self.ros_path, "--catkin", "--cmake-prefix-path=foo"])) self.assertFalse(os.path.exists(os.path.join(self.local_path, 'setup.sh'))) self.assertFalse(os.path.exists(os.path.join(self.local_path, 'setup.bash'))) self.assertFalse(os.path.exists(os.path.join(self.local_path, 'setup.zsh'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, '.rosinstall'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'CMakeLists.txt'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'workspace-config.cmake')))
def test_merge(self): workspace = os.path.join(self.test_root_path, 'ws2') cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([workspace, self.simple_rosinstall])) self.assertEqual(0, cli.cmd_merge(workspace, [self.simple_changed_vcs_rosinstall, '-y'])) self.assertFalse(os.path.isdir(os.path.join(workspace, 'hgrepo'))) self.assertFalse(os.path.isdir(os.path.join(workspace, 'hgrepo', '.hg'))) self.assertEqual(0, cli.cmd_update(workspace, [])) self.assertTrue(os.path.isdir(os.path.join(workspace, 'hgrepo'))) self.assertTrue(os.path.isdir(os.path.join(workspace, 'hgrepo', '.hg'))) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') self.assertEqual(3, len(config.get_config_elements()))
def test_multi_status_rosws_outside(self): """Test rosws status output when run outside workspace. In particular asserts that there are newlines between statuses, and no overlaps""" cmd = ["rosws", "status", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() rosws_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.assertStatusListEqual('A clone_git/added.txt\n D clone_git/deleted-fs.txt\nD clone_git/deleted.txt\n M clone_git/modified-fs.txt\nM clone_git/modified.txt\nA clone_svn/added.txt\nD clone_svn/deleted.txt\n! clone_svn/deleted-fs.txt\nM clone_svn/modified.txt\nM clone_hg/modified-fs.txt\nM clone_hg/modified.txt\nA clone_hg/added.txt\nR clone_hg/deleted.txt\n! clone_hg/deleted-fs.txt\n+N clone_bzr/added.txt\n D clone_bzr/deleted-fs.txt\n-D clone_bzr/deleted.txt\n M clone_bzr/modified-fs.txt\n M clone_bzr/modified.txt\nA clone_git2/added.txt\n D clone_git2/deleted-fs.txt\nD clone_git2/deleted.txt\n M clone_git2/modified-fs.txt\nM clone_git2/modified.txt\n', output) cli = RoswsCLI() self.assertEqual(0, cli.cmd_status(os.path.join(self.test_root_path, 'ws'), []))
def test_multi_diff_rosws_outside(self): '''Test rosws diff output from outside workspace. In particular asserts that there are newlines between diffs, and no overlaps''' cmd = ["rosws", "diff", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() rosws_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.check_diff_output(output) cli = RoswsCLI() self.assertEqual(0, cli.cmd_diff(os.path.join(self.test_root_path, 'ws'), []))
def test_multi_diff_rosws_outside(self): '''Test rosws diff output from outside workspace. In particular asserts that there are newlines between diffs, and no overlaps''' cmd = ["rosws", "diff", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() rosws_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.check_diff_output(output) cli = RoswsCLI() self.assertEqual( 0, cli.cmd_diff(os.path.join(self.test_root_path, 'ws'), []))
def test_rosws_info_git(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', 'M', 'git'], tokens[0:3]) tokens2 = _nth_line_split(-1, output) self.assertEqual(1, len(tokens2)) self.assertEqual('../ros', tokens2[0]) cli = RoswsCLI() self.assertEqual(0, cli.cmd_info(os.path.join(self.test_root_path, 'ws'), []))
def test_cmd_remove(self): # rosinstall to create dir self.local_path = os.path.join(self.test_root_path, "ws12") cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([self.local_path, self.ros_path])) self.assertEqual(0, cli.cmd_merge(self.local_path, [self.git_path, "-y"])) self.assertEqual(0, cli.cmd_merge(self.local_path, [self.hg_path, "-y"])) config = rosinstall.multiproject_cmd.get_config(basepath=self.local_path, config_filename='.rosinstall') self.assertEqual(len(config.get_config_elements()), 3) self.assertEqual(0, cli.cmd_remove(self.local_path, [self.git_path])) config = rosinstall.multiproject_cmd.get_config(basepath=self.local_path, config_filename='.rosinstall') self.assertEqual(len(config.get_config_elements()), 2)
def test_multi_diff_rosws_inside(self): '''Test rosws diff output from inside workspace. In particular asserts that there are newlines between diffs, and no overlaps''' directory = self.test_root_path + "/ws" cmd = ["rosws", "diff"] os.chdir(directory) sys.stdout = output = StringIO() rosws_main(cmd) output = output.getvalue() sys.stdout = sys.__stdout__ self.check_diff_output(output) cli = RoswsCLI() self.assertEqual(0, cli.cmd_diff(directory, []))
def test_cmd_init(self): self.local_path = os.path.join(self.test_root_path, "ws5") os.makedirs(self.local_path) cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([self.local_path, self.ros_path])) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'setup.sh'))) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'setup.bash'))) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'setup.zsh'))) self.assertTrue( os.path.exists(os.path.join(self.local_path, '.rosinstall'))) self.assertEqual( 0, subprocess.call(". %s" % os.path.join(self.local_path, 'setup.sh'), shell=True, env=self.new_environ)) self.assertEqual( 0, subprocess.call(". %s" % os.path.join(self.local_path, 'setup.bash'), shell=True, env=self.new_environ, executable='/bin/bash')) self.assertEqual(0, cli.cmd_merge(self.local_path, [self.ros_path, "-y"])) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'setup.sh'))) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'setup.bash'))) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'setup.zsh'))) self.assertTrue( os.path.exists(os.path.join(self.local_path, '.rosinstall'))) self.assertEqual( 0, subprocess.call(". %s" % os.path.join(self.local_path, 'setup.sh'), shell=True, env=self.new_environ)) self.assertEqual( 0, subprocess.call(". %s" % os.path.join(self.local_path, 'setup.bash'), shell=True, env=self.new_environ, executable='/bin/bash'))
def test_multi_status_rosws_outside(self): """Test rosws status output when run outside workspace. In particular asserts that there are newlines between statuses, and no overlaps""" cmd = ["rosws", "status", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() rosws_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.assertStatusListEqual( 'A clone_git/added.txt\n D clone_git/deleted-fs.txt\nD clone_git/deleted.txt\n M clone_git/modified-fs.txt\nM clone_git/modified.txt\nA clone_svn/added.txt\nD clone_svn/deleted.txt\n! clone_svn/deleted-fs.txt\nM clone_svn/modified.txt\nM clone_hg/modified-fs.txt\nM clone_hg/modified.txt\nA clone_hg/added.txt\nR clone_hg/deleted.txt\n! clone_hg/deleted-fs.txt\n+N clone_bzr/added.txt\n D clone_bzr/deleted-fs.txt\n-D clone_bzr/deleted.txt\n M clone_bzr/modified-fs.txt\n M clone_bzr/modified.txt\nA clone_git2/added.txt\n D clone_git2/deleted-fs.txt\nD clone_git2/deleted.txt\n M clone_git2/modified-fs.txt\nM clone_git2/modified.txt\n', output) cli = RoswsCLI() self.assertEqual( 0, cli.cmd_status(os.path.join(self.test_root_path, 'ws'), []))
def test_setup_sh(self): self.local_path = os.path.join(self.test_root_path, "ws13") cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([self.local_path, self.simple_rosinstall])) command = "echo $ROS_WORKSPACE" self.execute_check_result_allshells(command, self.local_path, expect=self.local_path) self.execute_check_result_allshells(command, '.', cwd=self.local_path, expect=self.local_path) self.execute_check_result_allshells(command, 'ws13', cwd=self.test_root_path, expect=self.local_path) local_ros_path = os.path.join(self.local_path, "ros") local_git_path = os.path.join(self.local_path, "gitrepo") package_path = "%s:%s" % (local_git_path, local_ros_path) command = "echo $ROS_PACKAGE_PATH" self.execute_check_result_allshells(command, self.local_path, expect=package_path) self.execute_check_result_allshells(command, '.', cwd=self.local_path, expect=package_path) self.execute_check_result_allshells(command, 'ws13', cwd=self.test_root_path, expect=package_path)
def test_cmd_init_catkin2(self): self.local_path = os.path.join(self.test_root_path, "ws7") os.makedirs(self.local_path) cli = RoswsCLI() self.assertEqual( 0, cli.cmd_init([self.local_path, self.ros_path, "--catkin"])) self.assertFalse( os.path.exists(os.path.join(self.local_path, 'setup.sh'))) self.assertFalse( os.path.exists(os.path.join(self.local_path, 'setup.bash'))) self.assertFalse( os.path.exists(os.path.join(self.local_path, 'setup.zsh'))) self.assertTrue( os.path.exists(os.path.join(self.local_path, '.rosinstall'))) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'CMakeLists.txt')))
def test_init(self): workspace = os.path.join(self.test_root_path, 'ws1') cli = RoswsCLI() try: cli.cmd_init([workspace, 'foo', 'bar']) fail("expected exit") except SystemExit: pass self.assertEqual(0, cli.cmd_init([workspace, self.simple_rosinstall])) self.assertTrue(os.path.exists(workspace)) self.assertTrue(os.path.exists(os.path.join(workspace, '.rosinstall'))) self.assertTrue(os.path.exists(os.path.join(workspace, 'setup.sh'))) self.assertTrue(os.path.isdir(os.path.join(workspace, 'ros'))) self.assertTrue(os.path.isdir(os.path.join(workspace, 'gitrepo'))) self.assertTrue(os.path.isdir(os.path.join(workspace, 'gitrepo', '.git'))) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') self.assertEqual(2, len(config.get_config_elements()))
def test_set_add_scm_change_localname(self): workspace = os.path.join(self.test_root_path, 'ws8') cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([workspace, self.ros_path])) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') self.assertEqual(1, len(config.get_config_elements())) self.assertEqual(os.path.join(self.test_root_path, 'ros'), config.get_config_elements()[0].get_local_name()) # use a weird absolute localname self.assertEqual(0, cli.cmd_set(workspace, [os.path.join(workspace, '..', 'ws8', 'hgrepo'), '../hgrepo', '-y', '--hg'])) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') self.assertEqual(2, len(config.get_config_elements())) self.assertEqual('hgrepo', config.get_config_elements()[1].get_local_name()) oldcwd = os.getcwd() try: os.chdir(self.test_root_path) # try pointing to a relative dir that also exists elsewhere try: cli.cmd_set(workspace, ['gitrepo', '../gitrepo', '-y', '--hg']) self.fail("Expected SystemExit") except SystemExit: pass # use a weird relative localname self.assertEqual(0, cli.cmd_set(workspace, [os.path.join('ws8', 'gitrepo'), '../gitrepo', '-y', '--hg'])) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') self.assertEqual(3, len(config.get_config_elements())) self.assertEqual('hgrepo', config.get_config_elements()[1].get_local_name()) self.assertEqual('gitrepo', config.get_config_elements()[2].get_local_name()) finally: os.chdir(oldcwd)
def test_cmd_generate_ros_files_build(self): self.local_path = os.path.join(self.test_root_path, "ws2b") os.makedirs(self.local_path) local_rosinstall = os.path.join(self.test_root_path, "local.rosinstall") _create_yaml_file([ _create_config_elt_dict("git", 'ros_comm', self.git_path), _create_config_elt_dict("git", 'ros', self.ros_path), _create_config_elt_dict("hg", 'hgrepo', self.hg_path) ], local_rosinstall) cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([self.local_path, local_rosinstall])) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'setup.sh'))) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'setup.bash'))) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'setup.zsh')))
def test_setup_sh_relros(self): self.local_path = os.path.join(self.test_root_path, "ws14") cli = RoswsCLI() simple_rel_rosinstall = os.path.join(self.test_root_path, "simple_rel.rosinstall") _create_yaml_file([_create_config_elt_dict("git", "ros", "../ros")], simple_rel_rosinstall) self.assertEqual(0, cli.cmd_init([self.local_path, simple_rel_rosinstall])) command = "echo $ROS_WORKSPACE" self.execute_check_result_allshells(command, self.local_path, expect=self.local_path) self.execute_check_result_allshells(command, '.', cwd=self.local_path, expect=self.local_path) self.execute_check_result_allshells(command, 'ws14', cwd=self.test_root_path, expect=self.local_path) package_path = os.path.join(self.local_path, "ros") command = "echo $ROS_PACKAGE_PATH" self.execute_check_result_allshells(command, self.local_path, expect=package_path) self.execute_check_result_allshells(command, '.', cwd=self.local_path, expect=package_path) self.execute_check_result_allshells(command, 'ws14', cwd=self.test_root_path, expect=package_path)
def test_cmd_init(self): self.local_path = os.path.join(self.test_root_path, "ws5") os.makedirs(self.local_path) cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([self.local_path, self.ros_path])) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'setup.sh'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'setup.bash'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'setup.zsh'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, '.rosinstall'))) self.assertEqual(0, subprocess.call(". %s" % os.path.join(self.local_path, 'setup.sh'), shell=True, env=self.new_environ)) self.assertEqual(0, subprocess.call(". %s" % os.path.join(self.local_path, 'setup.bash'), shell=True, env=self.new_environ, executable='/bin/bash')) self.assertEqual(0, cli.cmd_merge(self.local_path, [self.ros_path, "-y"])) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'setup.sh'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'setup.bash'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'setup.zsh'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, '.rosinstall'))) self.assertEqual(0, subprocess.call(". %s" % os.path.join(self.local_path, 'setup.sh'), shell=True, env=self.new_environ)) self.assertEqual(0, subprocess.call(". %s" % os.path.join(self.local_path, 'setup.bash'), shell=True, env=self.new_environ, executable='/bin/bash'))
def test_Rosinstall_diff_svn_outside(self): """Test diff output for svn when run outside workspace""" cmd = ["rosinstall", "ws", "--diff"] os.chdir(self.test_root_path) sys.stdout = output = StringIO(); rosinstall_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.check_diff_output(output) cmd = ["rosws", "diff", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO(); rosws_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.check_diff_output(output) cli = RoswsCLI() self.assertEqual(0, cli.cmd_diff(os.path.join(self.test_root_path, 'ws'), []))
def test_Rosinstall_diff_hg_outside(self): """Test diff output for hg when run outside workspace""" cmd = ["rosinstall", "ws", "--diff"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() rosinstall_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.check_diff_output(output) cmd = ["rosws", "diff", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() rosws_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.check_diff_output(output) cli = RoswsCLI() self.assertEqual(0, cli.cmd_diff(os.path.join(self.test_root_path, 'ws'), []))
def test_Rosinstall_diff_bzr_inside(self): """Test diff output for bzr when run inside workspace""" directory = self.test_root_path + "/ws" cmd = ["rosinstall", ".", "--diff"] os.chdir(directory) sys.stdout = output = StringIO() rosinstall_main(cmd) output = output.getvalue() self.check_diff_output(output) cmd = ["rosws", "diff"] os.chdir(directory) sys.stdout = output = StringIO() rosws_main(cmd) output = output.getvalue() sys.stdout = sys.__stdout__ self.check_diff_output(output) cli = RoswsCLI() self.assertEqual(0, cli.cmd_diff(directory, []))
def test_Rosinstall_status_hg_inside(self): """Test status output for hg when run inside workspace""" directory = self.test_root_path + "/ws" cmd = ["rosinstall", ".", "--status"] os.chdir(directory) sys.stdout = output = StringIO() rosinstall_main(cmd) output = output.getvalue() self.assertEqual('M clone/modified-fs.txt\nM clone/modified.txt\nA clone/added.txt\nR clone/deleted.txt\n! clone/deleted-fs.txt\n', output) cmd = ["rosws", "status"] os.chdir(directory) sys.stdout = output = StringIO() rosws_main(cmd) output = output.getvalue() sys.stdout = sys.__stdout__ self.assertEqual('M clone/modified-fs.txt\nM clone/modified.txt\nA clone/added.txt\nR clone/deleted.txt\n! clone/deleted-fs.txt\n', output) cli = RoswsCLI() self.assertEqual(0, cli.cmd_diff(directory, []))
def test_Rosinstall_diff_hg_inside(self): """Test diff output for hg when run inside workspace""" directory = self.test_root_path + "/ws" cmd = ["rosinstall", ".", "--diff"] os.chdir(directory) sys.stdout = output = StringIO() rosinstall_main(cmd) output = output.getvalue() self.check_diff_output(output) cmd = ["rosws", "diff"] os.chdir(directory) sys.stdout = output = StringIO() rosws_main(cmd) output = output.getvalue() sys.stdout = sys.__stdout__ self.check_diff_output(output) cli = RoswsCLI() self.assertEqual(0, cli.cmd_status(directory, []))
def test_Rosinstall_status_hg_untracked(self): """Test untracked status output for hg when run outside workspace""" cmd = ["rosinstall", "ws", "--status-untracked"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() rosinstall_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.assertEqual('M clone/modified-fs.txt\nM clone/modified.txt\nA clone/added.txt\nR clone/deleted.txt\n! clone/deleted-fs.txt\n? clone/added-fs.txt\n', output) cmd = ["rosws", "status", "-t", "ws", "--untracked"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() rosws_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.assertEqual('M clone/modified-fs.txt\nM clone/modified.txt\nA clone/added.txt\nR clone/deleted.txt\n! clone/deleted-fs.txt\n? clone/added-fs.txt\n', output) cli = RoswsCLI() self.assertEqual(0, cli.cmd_status(os.path.join(self.test_root_path, 'ws'), ["--untracked"]))
def test_multi_status_untracked(self): '''tests status output for --untracked. In particular asserts that there are newlines between statuses, and no overlaps''' cmd = ["rosinstall", "ws", "--status-untracked"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() rosinstall_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.assertStatusListEqual('A clone_git/added.txt\n D clone_git/deleted-fs.txt\nD clone_git/deleted.txt\n M clone_git/modified-fs.txt\nM clone_git/modified.txt\n?? clone_git/added-fs.txt\n? clone_svn/added-fs.txt\nA clone_svn/added.txt\nD clone_svn/deleted.txt\n! clone_svn/deleted-fs.txt\nM clone_svn/modified.txt\nM clone_hg/modified-fs.txt\nM clone_hg/modified.txt\nA clone_hg/added.txt\nR clone_hg/deleted.txt\n! clone_hg/deleted-fs.txt\n? clone_hg/added-fs.txt\n? clone_bzr/added-fs.txt\n+N clone_bzr/added.txt\n D clone_bzr/deleted-fs.txt\n-D clone_bzr/deleted.txt\n M clone_bzr/modified-fs.txt\n M clone_bzr/modified.txt\nA clone_git2/added.txt\n D clone_git2/deleted-fs.txt\nD clone_git2/deleted.txt\n M clone_git2/modified-fs.txt\nM clone_git2/modified.txt\n?? clone_git2/added-fs.txt\n', output) cmd = ["rosws", "status", "-t", "ws", "--untracked"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() rosws_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.assertStatusListEqual('A clone_git/added.txt\n D clone_git/deleted-fs.txt\nD clone_git/deleted.txt\n M clone_git/modified-fs.txt\nM clone_git/modified.txt\n?? clone_git/added-fs.txt\n? clone_svn/added-fs.txt\nA clone_svn/added.txt\nD clone_svn/deleted.txt\n! clone_svn/deleted-fs.txt\nM clone_svn/modified.txt\nM clone_hg/modified-fs.txt\nM clone_hg/modified.txt\nA clone_hg/added.txt\nR clone_hg/deleted.txt\n! clone_hg/deleted-fs.txt\n? clone_hg/added-fs.txt\n? clone_bzr/added-fs.txt\n+N clone_bzr/added.txt\n D clone_bzr/deleted-fs.txt\n-D clone_bzr/deleted.txt\n M clone_bzr/modified-fs.txt\n M clone_bzr/modified.txt\nA clone_git2/added.txt\n D clone_git2/deleted-fs.txt\nD clone_git2/deleted.txt\n M clone_git2/modified-fs.txt\nM clone_git2/modified.txt\n?? clone_git2/added-fs.txt\n', output) cli = RoswsCLI() self.assertEqual(0, cli.cmd_status(os.path.join(self.test_root_path, 'ws'), ["--untracked"]))
def test_cmd_init_no_ros(self): self.local_path = os.path.join(self.test_root_path, "ws10") ros_root_existed = False if 'ROS_ROOT' in os.environ: ros_root_existed = True oldros = os.environ.pop('ROS_ROOT') cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([self.local_path])) shutil.rmtree(self.local_path) os.environ['ROS_ROOT'] = self.ros_path self.assertEqual(0, cli.cmd_init([self.local_path])) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'setup.sh'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'setup.bash'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'setup.zsh'))) if ros_root_existed: os.environ['ROS_ROOT'] = oldros else: os.environ.pop('ROS_ROOT')
def test_set_add_plain(self): workspace = os.path.join(self.test_root_path, 'ws5') cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([workspace, self.simple_rosinstall])) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') self.assertEqual(2, len(config.get_config_elements())) self.assertEqual('ros', config.get_config_elements()[0].get_local_name()) self.assertEqual('gitrepo', config.get_config_elements()[1].get_local_name()) # detached self.assertEqual(0, cli.cmd_set(workspace, [os.path.join(workspace, 'foo'), '-y'])) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') self.assertEqual(3, len(config.get_config_elements())) self.assertEqual('ros', config.get_config_elements()[0].get_local_name()) self.assertEqual('gitrepo', config.get_config_elements()[1].get_local_name()) self.assertEqual(False, config.get_config_elements()[2].is_vcs_element()) self.assertEqual('foo', config.get_config_elements()[2].get_local_name()) self.assertEqual(0, cli.cmd_set(workspace, [os.path.join(workspace, 'hgrepo'), '-y', '--detached'])) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') self.assertEqual(4, len(config.get_config_elements())) self.assertEqual('ros', config.get_config_elements()[0].get_local_name()) self.assertEqual('gitrepo', config.get_config_elements()[1].get_local_name()) self.assertEqual(False, config.get_config_elements()[2].is_vcs_element()) self.assertEqual('foo', config.get_config_elements()[2].get_local_name()) self.assertEqual(False, config.get_config_elements()[3].is_vcs_element()) self.assertEqual('hgrepo', config.get_config_elements()[3].get_local_name()) # turn into scm repo self.assertEqual(0, cli.cmd_set(workspace, [os.path.join(workspace, 'hgrepo'), '../hgrepo', '-y', '--hg'])) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') self.assertEqual(4, len(config.get_config_elements())) self.assertEqual('ros', config.get_config_elements()[0].get_local_name()) self.assertEqual('gitrepo', config.get_config_elements()[1].get_local_name()) self.assertTrue(config.get_config_elements()[3].is_vcs_element()) self.assertEqual('hgrepo', config.get_config_elements()[3].get_local_name())
def test_info_only(self): workspace = os.path.join(self.test_root_path, 'ws7') cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([workspace, self.simple_rosinstall])) # pkg_path sys.stdout = output = StringIO() self.assertEqual(0, cli.cmd_info(workspace, ['--pkg-path-only'])) output = output.getvalue() self.assertEqual(os.path.join(workspace, 'gitrepo'), output.strip()) sys.stdout = output = StringIO() self.assertEqual(0, cli.cmd_info(workspace, ['--only=localname'])) output = output.getvalue() self.assertEqual('ros\ngitrepo', output.strip()) sys.stdout = output = StringIO() self.assertEqual(0, cli.cmd_info(workspace, ['--only=version'])) output = output.getvalue() self.assertEqual('', output.strip()) sys.stdout = output = StringIO() self.assertEqual(0, cli.cmd_info(workspace, ['--only=uri'])) output = output.getvalue() self.assertEqual('%s\n%s\n' % (os.path.join(self.test_root_path, 'ros'), os.path.join(self.test_root_path, 'gitrepo')), output) sys.stdout = output = StringIO() self.assertEqual(0, cli.cmd_info(workspace, ['--only=cur_revision'])) output = output.getvalue() self.assertEqual(82, len(output)) sys.stdout = sys.__stdout__ # pairs sys.stdout = output = StringIO(); self.assertEqual(0, cli.cmd_info(workspace, ['--only=localname,scmtype'])) output = output.getvalue() self.assertEqual('ros,git\ngitrepo,git', output.strip()) sys.stdout = output = StringIO(); self.assertEqual(0, cli.cmd_info(workspace, ['--only=scmtype,localname'])) output = output.getvalue() self.assertEqual('git,ros\ngit,gitrepo', output.strip())
def test_setup_sh_relother(self): self.local_path = os.path.join(self.test_root_path, "ws15") cli = RoswsCLI() simple_rel_rosinstall = os.path.join(self.test_root_path, "simple_rel2.rosinstall") _create_yaml_file([ _create_config_elt_dict("git", "ros", "../ros"), _create_config_elt_dict("other", "../gitrepo") ], simple_rel_rosinstall) self.assertEqual( 0, cli.cmd_init([self.local_path, simple_rel_rosinstall])) command = "echo $ROS_WORKSPACE" self.execute_check_result_allshells(command, self.local_path, expect=self.local_path) self.execute_check_result_allshells(command, '.', cwd=self.local_path, expect=self.local_path) self.execute_check_result_allshells(command, 'ws15', cwd=self.test_root_path, expect=self.local_path) local_ros_path = os.path.join(self.local_path, "ros") package_path = "%s:%s" % (self.git_path, local_ros_path) command = "echo $ROS_PACKAGE_PATH" self.execute_check_result_allshells(command, self.local_path, expect=package_path) self.execute_check_result_allshells(command, '.', cwd=self.local_path, expect=package_path) self.execute_check_result_allshells(command, 'ws15', cwd=self.test_root_path, expect=package_path)
def test_Rosinstall_status_git_outside(self): """Test status output for git when run outside workspace""" cmd = ["rosinstall", "ws", "--status"] os.chdir(self.test_root_path) sys.stdout = output = StringIO(); rosinstall_main(cmd) sys.stdout = output = StringIO(); rosinstall_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.assertEqual('A clone/added.txt\n D clone/deleted-fs.txt\nD clone/deleted.txt\n M clone/modified-fs.txt\nM clone/modified.txt\n', output) cmd = ["rosws", "status", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO(); rosws_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.assertEqual('A clone/added.txt\n D clone/deleted-fs.txt\nD clone/deleted.txt\n M clone/modified-fs.txt\nM clone/modified.txt\n', output) cli = RoswsCLI() self.assertEqual(0, cli.cmd_status(os.path.join(self.test_root_path, 'ws'), []))
def test_Rosinstall_status_svn_outside(self): """Test status output for svn when run outside workspace""" cmd = ["rosinstall", "ws", "--status"] cmd = ["rosinstall", "ws", "--status"] os.chdir(self.test_root_path) sys.stdout = output = StringIO(); rosinstall_main(cmd) sys.stdout = output = StringIO(); rosinstall_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.assertStatusListEqual('A clone/added.txt\nD clone/deleted.txt\n! clone/deleted-fs.txt\nM clone/modified.txt\n', output) cmd = ["rosws", "status", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO(); rosws_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.assertStatusListEqual('A clone/added.txt\nD clone/deleted.txt\n! clone/deleted-fs.txt\nM clone/modified.txt\n', output) cli = RoswsCLI() self.assertEqual(0, cli.cmd_status(os.path.join(self.test_root_path, 'ws'), []))
def prepare_workspace(path: str) -> None: """Prepare workspace at the given path. This is equivalent to calling `rosws init` on the given path. Internal use only. Args: path (str): Local workspace path. """ cli = RoswsCLI() cli.cmd_init([path]) # Fix setup.sh path with open(os.path.join(path, "setup.sh"), "r") as f: script = f.read() newpath = "export ROS_WORKSPACE=/workspace/fido_ws\n" script = re.sub(r"(export ROS_WORKSPACE=).*(\n)", newpath, script) with open(os.path.join(path, "setup.sh"), "w") as f: f.write(script)
def test_cmd_init_catkinpp(self): self.local_path = os.path.join(self.test_root_path, "ws8") os.makedirs(self.local_path) cli = RoswsCLI() self.assertEqual( 0, cli.cmd_init([ self.local_path, self.ros_path, "--catkin", "--cmake-prefix-path=foo" ])) self.assertFalse( os.path.exists(os.path.join(self.local_path, 'setup.sh'))) self.assertFalse( os.path.exists(os.path.join(self.local_path, 'setup.bash'))) self.assertFalse( os.path.exists(os.path.join(self.local_path, 'setup.zsh'))) self.assertTrue( os.path.exists(os.path.join(self.local_path, '.rosinstall'))) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'CMakeLists.txt'))) self.assertTrue( os.path.exists( os.path.join(self.local_path, 'workspace-config.cmake')))
def test_cmd_init_no_ros(self): self.local_path = os.path.join(self.test_root_path, "ws10") ros_root_existed = False if 'ROS_ROOT' in os.environ: ros_root_existed = True oldros = os.environ.pop('ROS_ROOT') cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([self.local_path])) shutil.rmtree(self.local_path) os.environ['ROS_ROOT'] = self.ros_path self.assertEqual(0, cli.cmd_init([self.local_path])) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'setup.sh'))) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'setup.bash'))) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'setup.zsh'))) if ros_root_existed: os.environ['ROS_ROOT'] = oldros else: os.environ.pop('ROS_ROOT')
def test_remove(self): workspace = os.path.join(self.test_root_path, 'ws3') cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([workspace, self.simple_rosinstall])) self.assertEqual(0, cli.cmd_merge(workspace, [self.simple_changed_vcs_rosinstall, '-y'])) self.assertEqual(0, cli.cmd_update(workspace, [])) config = wstool.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') self.assertEqual(3, len(config.get_config_elements())) self.assertEqual(0, cli.cmd_remove(workspace, ['hgrepo'])) config = wstool.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') self.assertEqual(2, len(config.get_config_elements()))
def test_cmd_remove(self): # rosinstall to create dir self.local_path = os.path.join(self.test_root_path, "ws12") cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([self.local_path, self.ros_path])) self.assertEqual(0, cli.cmd_merge(self.local_path, [self.git_path, "-y"])) self.assertEqual(0, cli.cmd_merge(self.local_path, [self.hg_path, "-y"])) config = rosinstall.multiproject_cmd.get_config( basepath=self.local_path, config_filename='.rosinstall') self.assertEqual(len(config.get_config_elements()), 3) self.assertEqual(0, cli.cmd_remove(self.local_path, [self.git_path])) config = rosinstall.multiproject_cmd.get_config( basepath=self.local_path, config_filename='.rosinstall') self.assertEqual(len(config.get_config_elements()), 2)
def test_set_detached(self): workspace = os.path.join(self.test_root_path, 'ws4') cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([workspace, self.simple_rosinstall])) self.assertEqual(0, cli.cmd_merge(workspace, [self.simple_changed_vcs_rosinstall, '-y'])) self.assertEqual(0, cli.cmd_update(workspace, [])) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') self.assertEqual(3, len(config.get_config_elements())) self.assertEqual('ros', config.get_config_elements()[0].get_local_name()) self.assertEqual('gitrepo', config.get_config_elements()[1].get_local_name()) self.assertEqual(True, config.get_config_elements()[1].is_vcs_element()) self.assertEqual('hgrepo', config.get_config_elements()[2].get_local_name()) self.assertEqual(0, cli.cmd_set(workspace, [os.path.join(workspace, 'gitrepo'), '--detached', '-y'])) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') self.assertEqual(3, len(config.get_config_elements())) self.assertEqual('ros', config.get_config_elements()[0].get_local_name()) self.assertEqual('gitrepo', config.get_config_elements()[1].get_local_name()) self.assertEqual(False, config.get_config_elements()[1].is_vcs_element()) self.assertEqual('hgrepo', config.get_config_elements()[2].get_local_name())
def test_init_parallel(self): workspace = os.path.join(self.test_root_path, 'ws1d') cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([workspace, self.simple_rosinstall, "--parallel=5"])) self.assertTrue(os.path.exists(workspace)) self.assertTrue(os.path.exists(os.path.join(workspace, '.rosinstall')))
def test_set_add_scm(self): workspace = os.path.join(self.test_root_path, 'ws6') cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([workspace, self.simple_rosinstall])) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') self.assertEqual(2, len(config.get_config_elements())) self.assertEqual('ros', config.get_config_elements()[0].get_local_name()) self.assertEqual('gitrepo', config.get_config_elements()[1].get_local_name()) # scm repo self.assertEqual(0, cli.cmd_set(workspace, [os.path.join(workspace, 'hgrepo'), '../hgrepo', '-y', '--hg'])) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') self.assertEqual(3, len(config.get_config_elements())) self.assertEqual('ros', config.get_config_elements()[0].get_local_name()) self.assertEqual('gitrepo', config.get_config_elements()[1].get_local_name()) self.assertTrue(config.get_config_elements()[2].is_vcs_element()) self.assertEqual('hgrepo', config.get_config_elements()[2].get_local_name()) self.assertFalse(os.path.exists(os.path.join(workspace, 'hgrepo'))) self.assertEqual(0, cli.cmd_update(workspace, [])) self.assertTrue(os.path.exists(os.path.join(workspace, 'hgrepo'))) path_spec = config.get_config_elements()[2].get_versioned_path_spec() self.assertFalse(path_spec is None) self.assertEqual(None, path_spec.get_version()) self.assertEqual(None, path_spec.get_revision()) self.assertFalse(path_spec.get_current_revision() is None) self.assertEqual(0, cli.cmd_set(workspace, [os.path.join(workspace, 'hgrepo'), '--version-new=0', '-y'])) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') path_spec = config.get_config_elements()[2].get_versioned_path_spec() self.assertEqual('0', path_spec.get_version()) self.assertFalse(path_spec.get_revision() is None) self.assertFalse(path_spec.get_current_revision() is None) self.assertEqual(path_spec.get_revision(), path_spec.get_current_revision()) # change in FS to version 1 subprocess.check_call(["touch", "hgfixed2.txt"], cwd=os.path.join(workspace, 'hgrepo')) subprocess.check_call(["hg", "add", "hgfixed2.txt"], cwd=os.path.join(workspace, 'hgrepo')) subprocess.check_call(["hg", "commit", "-m", "2nd"], cwd=os.path.join(workspace, 'hgrepo')) self.assertTrue(os.path.exists(os.path.join(workspace, 'hgrepo', 'hgfixed2.txt'))) path_spec = config.get_config_elements()[2].get_versioned_path_spec() self.assertEqual('0', path_spec.get_version()) self.assertFalse(path_spec.get_revision() is None) self.assertFalse(path_spec.get_current_revision() is None) self.assertNotEqual(path_spec.get_revision(), path_spec.get_current_revision()) # revert FS to spec self.assertEqual(0, cli.cmd_update(workspace, [])) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') path_spec = config.get_config_elements()[2].get_versioned_path_spec() self.assertEqual('0', path_spec.get_version()) self.assertFalse(path_spec.get_revision() is None) self.assertFalse(path_spec.get_current_revision() is None) self.assertEqual(path_spec.get_revision(), path_spec.get_current_revision()) # change spec to 1 self.assertEqual(0, cli.cmd_set(workspace, [os.path.join(workspace, 'hgrepo'), '--version-new=1', '-y'])) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') path_spec = config.get_config_elements()[2].get_versioned_path_spec() self.assertEqual('1', path_spec.get_version()) self.assertFalse(path_spec.get_revision() is None) self.assertFalse(path_spec.get_current_revision() is None) self.assertNotEqual(path_spec.get_revision(), path_spec.get_current_revision()) # setting version to '' self.assertEqual(0, cli.cmd_set(workspace, [os.path.join(workspace, 'hgrepo'), "--version-new=''", '-y'])) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') path_spec = config.get_config_elements()[2].get_versioned_path_spec() self.assertEqual(None, path_spec.get_version()) self.assertTrue(path_spec.get_revision() is None) self.assertFalse(path_spec.get_current_revision() is None) self.assertEqual(0, cli.cmd_update(workspace, [])) config = rosinstall.multiproject_cmd.get_config(workspace, config_filename='.rosinstall') path_spec = config.get_config_elements()[2].get_versioned_path_spec() self.assertEqual(None, path_spec.get_version()) self.assertTrue(path_spec.get_revision() is None) self.assertFalse(path_spec.get_current_revision() is None)