def test_source(self): """checkout into temp dir and test setup files""" cmd = copy.copy(self.rosinstall_fn) self.simple_rosinstall = os.path.join(self.directory, "simple.rosinstall") _create_yaml_file([_create_config_elt_dict("svn", "ros", 'https://code.ros.org/svn/ros/stacks/ros/tags/boxturtle'), _create_config_elt_dict("svn", "ros_release", 'https://code.ros.org/svn/ros/stacks/ros_release/trunk')], self.simple_rosinstall) cmd.extend(['-j8', self.directory, self.simple_rosinstall]) self.assertTrue(rosinstall_main(cmd)) generated_rosinstall_filename = os.path.join(self.directory, ".rosinstall") self.assertTrue(os.path.exists(generated_rosinstall_filename)) self.assertTrue(os.path.exists(os.path.join(self.directory, "ros"))) self.assertTrue(os.path.exists(os.path.join(self.directory, "ros_release"))) self.assertTrue(os.path.exists(os.path.join(self.directory, "setup.sh"))) source_yaml = get_yaml_from_uri(generated_rosinstall_filename) self.assertEqual(source_yaml, [{'svn': { 'uri': 'https://code.ros.org/svn/ros/stacks/ros/tags/boxturtle', 'local-name': 'ros'} }, {'svn': { 'uri': 'https://code.ros.org/svn/ros/stacks/ros_release/trunk', 'local-name': 'ros_release'} } ]) subprocess.check_call(". %s" % os.path.join(self.directory, 'setup.sh'), shell=True, env=self.new_environ) subprocess.check_call(". %s" % os.path.join(self.directory, 'setup.bash'), shell=True, env=self.new_environ, executable='bash')
def test_twice_with_relpath(self): """runs rosinstall with generated self.simple_rosinstall to create local rosinstall env and creates a directory for a second local rosinstall env""" AbstractFakeRosBasedTest.setUp(self) self.rel_uri_rosinstall = os.path.join(self.test_root_path, "rel_uri.rosinstall") _create_yaml_file([ _create_config_elt_dict("git", "ros", self.ros_path), _create_config_elt_dict("git", "gitrepo", os.path.relpath(self.git_path)) ], self.rel_uri_rosinstall) config = rosinstall.multiproject_cmd.get_config( self.directory, [self.rel_uri_rosinstall, self.ros_path]) rosinstall.multiproject_cmd.cmd_install_or_update(config) config = rosinstall.multiproject_cmd.get_config( self.directory, [self.rel_uri_rosinstall, self.ros_path]) rosinstall.multiproject_cmd.cmd_install_or_update(config) self.rel_uri_rosinstall2 = os.path.join(self.test_root_path, "rel_uri.rosinstall2") # switch URIs to confuse config _create_yaml_file([ _create_config_elt_dict("git", "ros", os.path.relpath( self.git_path)), _create_config_elt_dict("git", "gitrepo", self.ros_path) ], self.rel_uri_rosinstall2) config = rosinstall.multiproject_cmd.get_config( self.directory, [self.rel_uri_rosinstall, self.ros_path]) rosinstall.multiproject_cmd.cmd_install_or_update(config)
def test_twice_with_relpath(self): """runs wstool with generated self.simple_rosinstall to create local wstool env and creates a directory for a second local wstool env""" AbstractFakeRosBasedTest.setUp(self) self.rel_uri_rosinstall = os.path.join(self.test_root_path, "rel_uri.rosinstall") _create_yaml_file([_create_config_elt_dict("git", "ros", self.ros_path), _create_config_elt_dict("git", "gitrepo", os.path.relpath(self.git_path))], self.rel_uri_rosinstall) config = wstool.multiproject_cmd.get_config(self.directory, [self.rel_uri_rosinstall, self.ros_path]) wstool.multiproject_cmd.cmd_info(config) wstool.multiproject_cmd.cmd_find_unmanaged_repos wstool.multiproject_cmd.cmd_install_or_update(config) config = wstool.multiproject_cmd.get_config(self.directory, [self.rel_uri_rosinstall, self.ros_path]) wstool.multiproject_cmd.cmd_install_or_update(config) self.rel_uri_rosinstall2 = os.path.join(self.test_root_path, "rel_uri.wstool2") # switch URIs to confuse config _create_yaml_file([_create_config_elt_dict("git", "ros", os.path.relpath(self.git_path)), _create_config_elt_dict("git", "gitrepo", self.ros_path)], self.rel_uri_rosinstall2) config = wstool.multiproject_cmd.get_config(self.directory, [self.rel_uri_rosinstall, self.ros_path]) wstool.multiproject_cmd.cmd_install_or_update(config)
def test_cmd_add(self): # rosinstall to create dir self.local_path = os.path.join(self.test_root_path, "ws33") cli = MultiprojectCLI(progname='multi_cli', config_filename='.rosinstall') simple_rel_rosinstall = os.path.join(self.test_root_path, "simple_rel3.rosinstall") _create_yaml_file([ _create_config_elt_dict(scmtype="git", uri=os.path.join(self.test_root_path, "ros"), localname='ros') ], simple_rel_rosinstall) self.assertEqual( 0, cli.cmd_init([self.local_path, simple_rel_rosinstall])) config = rosinstall.multiproject_cmd.get_config( basepath=self.local_path, config_filename='.rosinstall') self.assertEqual(1, len(config.get_config_elements())) self.assertEqual( 'git', config.get_config_elements()[0].get_path_spec().get_scmtype()) rosinstall.multiproject_cmd.add_uris(config, [self.local_path]) self.assertEqual(len(config.get_config_elements()), 1, config) self.assertEqual( 'git', config.get_config_elements()[0].get_path_spec().get_scmtype()) rosinstall.multiproject_cmd.add_uris( config, [os.path.join(self.local_path, '.rosinstall')]) self.assertEqual(len(config.get_config_elements()), 1, config) self.assertEqual( 'git', config.get_config_elements()[0].get_path_spec().get_scmtype())
def setUpClass(self): AbstractFakeRosBasedTest.setUpClass() # create another repo in git self.git_path2 = os.path.join(self.test_root_path, "gitrepo2") _create_git_repo(self.git_path2) self.simple_changed_uri_rosinstall = os.path.join(self.test_root_path, "simple_changed_uri.rosinstall") # same local name for gitrepo, different uri _create_yaml_file( [ _create_config_elt_dict("git", "ros", self.ros_path), _create_config_elt_dict("git", "gitrepo", self.git_path2), ], self.simple_changed_uri_rosinstall, ) # create a broken config self.broken_rosinstall = os.path.join(self.test_root_path, "broken.rosinstall") _create_yaml_file( [ _create_config_elt_dict("other", self.ros_path), _create_config_elt_dict("hg", "hgrepo", self.hg_path + "invalid"), ], self.broken_rosinstall, )
def setUpClass(self): AbstractFakeRosBasedTest.setUpClass() # create another repo in git self.tar_path = os.path.join(self.test_root_path, "tarfile.tar.bz2") _create_tar_file(self.tar_path) self.simple_tar_rosinstall = os.path.join(self.test_root_path, "simple_changed_uri.rosinstall") # same local name for gitrepo, different uri _create_yaml_file([_create_config_elt_dict("tar", "temptar", uri=self.tar_path, version='temptar')], self.simple_tar_rosinstall)
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_Rosinstall_rosinstall_file_input_ros_only(self): """uses base ros folder""" local_rosinstall = os.path.join(self.test_root_path, "local.rosinstall") # invalid recursion itno some other rosinstall folder _create_yaml_file([_create_config_elt_dict("other", self.directory)], local_rosinstall) cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.new_directory, self.ros_path, local_rosinstall]) self.assertTrue(rosinstall_main(cmd)) stream = open(os.path.join(self.new_directory, '.rosinstall'), 'r') yamlsrc = yaml.load(stream) stream.close() self.assertEqual(1, len(yamlsrc)) self.assertEqual('other', list(yamlsrc[0].keys())[0])
def test_Rosinstall_rosinstall_file_input_with_setupfile(self): local_rosinstall = os.path.join(self.test_root_path, "local.rosinstall") _create_yaml_file([_create_config_elt_dict("other", self.directory), _create_config_elt_dict("hg", "hgrepo", self.hg_path)], local_rosinstall) cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.new_directory, self.ros_path, local_rosinstall]) self.assertTrue(rosinstall_main(cmd)) stream = open(os.path.join(self.new_directory, '.rosinstall'), 'r') yamlsrc = yaml.load(stream) stream.close() self.assertEqual(2, len(yamlsrc), yamlsrc) self.assertEqual('other', list(yamlsrc[0].keys())[0]) # ros self.assertEqual('hg', list(yamlsrc[1].keys())[0]) # hg_repo
def test_source_boxturtle(self): """install boxturtle into temp dir""" cmd = copy.copy(self.rosinstall_fn) self.simple_rosinstall = os.path.join(self.directory, "simple.rosinstall") _create_yaml_file([ _create_config_elt_dict( "svn", "ros", 'https://code.ros.org/svn/ros/stacks/ros/tags/boxturtle'), _create_config_elt_dict( "svn", "ros_release", 'https://code.ros.org/svn/ros/stacks/ros_release/trunk') ], self.simple_rosinstall) cmd.extend([self.directory, self.simple_rosinstall]) self.assertTrue(rosinstall_main(cmd)) generated_rosinstall_filename = os.path.join(self.directory, ".rosinstall") self.assertTrue(os.path.exists(generated_rosinstall_filename)) self.assertTrue(os.path.exists(os.path.join(self.directory, "ros"))) self.assertTrue( os.path.exists(os.path.join(self.directory, "ros_release"))) self.assertTrue( os.path.exists(os.path.join(self.directory, "setup.sh"))) source_yaml = get_yaml_from_uri(generated_rosinstall_filename) self.assertEqual(source_yaml, [{ 'svn': { 'uri': 'https://code.ros.org/svn/ros/stacks/ros/tags/boxturtle', 'local-name': 'ros' } }, { 'svn': { 'uri': 'https://code.ros.org/svn/ros/stacks/ros_release/trunk', 'local-name': 'ros_release' } }]) self.assertEqual( 0, subprocess.call(". %s" % os.path.join(self.directory, 'setup.sh'), shell=True, env=self.new_environ)) self.assertEqual( 0, subprocess.call(". %s" % os.path.join(self.directory, 'setup.bash'), shell=True, env=self.new_environ, executable='/bin/bash'))
def test_Rosinstall_rosinstall_file_input_add(self): """uses base ros folders and adds a stack""" local_rosinstall = os.path.join(self.test_root_path, "local2.rosinstall") # self.directory points invalidly at a folder containing a .rosinstall pointing to ros and gitrepo _create_yaml_file([_create_config_elt_dict("other", self.directory), _create_config_elt_dict("hg", "gitrepo", self.hg_path)], local_rosinstall) cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.new_directory, self.ros_path, local_rosinstall]) self.assertTrue(rosinstall_main(cmd)) stream = open(os.path.join(self.new_directory, '.rosinstall'), 'r') yamlsrc = yaml.load(stream) stream.close() self.assertEqual(2, len(yamlsrc)) self.assertEqual('other', list(yamlsrc[0].keys())[0]) self.assertEqual('hg', list(yamlsrc[1].keys())[0])
def setUp(self): """runs rosinstall with generated self.simple_rosinstall to create local rosinstall env and creates a second directory self.new_directory for a second local rosinstall env""" AbstractFakeRosBasedTest.setUp(self) self.simple_fuerte_rosinstall = os.path.join(self.test_root_path, "simple_fuerte.rosinstall") _create_yaml_file([_create_config_elt_dict("git", "ros", self.ros_path), _create_config_elt_dict("setup-file", "setup.sh"), _create_config_elt_dict("hg", "hgrepo", self.hg_path)], self.simple_fuerte_rosinstall) # setup a rosinstall env as base for further tests cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.directory, self.simple_fuerte_rosinstall]) self.assertTrue(rosinstall_main(cmd)) self.new_directory = tempfile.mkdtemp() self.directories["new_ros_env"] = self.new_directory
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 setUpClass(self): AbstractFakeRosBasedTest.setUpClass() # create another repo in git self.git_path2 = os.path.join(self.test_root_path, "gitrepo2") _create_git_repo(self.git_path2) self.simple_changed_uri_rosinstall = os.path.join( self.test_root_path, "simple_changed_uri.rosinstall") # same local name for gitrepo, different uri _create_yaml_file([ _create_config_elt_dict("git", "ros", self.ros_path), _create_config_elt_dict("git", "gitrepo", self.git_path2) ], self.simple_changed_uri_rosinstall) # create a broken config self.broken_rosinstall = os.path.join(self.test_root_path, "broken.rosinstall") _create_yaml_file([ _create_config_elt_dict("other", self.ros_path), _create_config_elt_dict("hg", "hgrepo", self.hg_path + "invalid") ], self.broken_rosinstall)
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_cmd_add(self): # rosinstall to create dir self.local_path = os.path.join(self.test_root_path, "ws33") cli = MultiprojectCLI(progname='multi_cli', config_filename='.rosinstall') simple_rel_rosinstall = os.path.join(self.test_root_path, "simple_rel3.rosinstall") _create_yaml_file([_create_config_elt_dict(scmtype="git", uri=os.path.join(self.test_root_path, "ros"), localname='ros')], simple_rel_rosinstall) self.assertEqual(0, cli.cmd_init([self.local_path, simple_rel_rosinstall])) config = rosinstall.multiproject_cmd.get_config(basepath=self.local_path, config_filename='.rosinstall') self.assertEqual(1, len(config.get_config_elements())) self.assertEqual('git', config.get_config_elements()[0].get_path_spec().get_scmtype()) rosinstall.multiproject_cmd.add_uris(config, [self.local_path]) self.assertEqual(len(config.get_config_elements()), 1, config) self.assertEqual('git', config.get_config_elements()[0].get_path_spec().get_scmtype()) rosinstall.multiproject_cmd.add_uris(config, [os.path.join(self.local_path, '.rosinstall')]) self.assertEqual(len(config.get_config_elements()), 1, config) self.assertEqual('git', config.get_config_elements()[0].get_path_spec().get_scmtype())