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_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 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_delete_changes(self): cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.directory, self.simple_rosinstall]) self.assertTrue(rosinstall_main(cmd)) cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.directory, self.simple_changed_uri_rosinstall, "--delete-changed-uri"]) self.assertTrue(rosinstall_main(cmd))
def test_rosinstall_invalid_fail(self): cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.directory, self.broken_rosinstall]) try: rosinstall_main(cmd) self.fail("expected exception") except MultiProjectException: pass
def test_Rosinstall_help(self): cmd = copy.copy(self.rosinstall_fn) cmd.append("-h") try: rosinstall_main(cmd) self.fail("expected SystemExit") except SystemExit as e: self.assertEqual(0, e.code)
def test_multi_diff_rosinstall_inside(self): '''Test rosinstall diff output from inside workspace. In particular asserts that there are newlines between diffs, and no overlaps''' 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)
def test_rosinstall_backup_changes(self): cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.directory, self.simple_rosinstall]) self.assertTrue(rosinstall_main(cmd)) directory1 = tempfile.mkdtemp() self.directories["backup1"] = directory1 cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.directory, self.simple_changed_uri_rosinstall, "--backup-changed-uri=%s" % directory1]) self.assertTrue(rosinstall_main(cmd)) self.assertEqual(len(os.listdir(directory1)), 1)
def test_rosinstall_delete_changes(self): cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.directory, self.simple_rosinstall]) self.assertTrue(rosinstall_main(cmd)) cmd = copy.copy(self.rosinstall_fn) cmd.extend([ self.directory, self.simple_changed_uri_rosinstall, "--delete-changed-uri" ]) self.assertTrue(rosinstall_main(cmd))
def test_multi_diff_rosinstall_outside(self): '''Test rosinstall diff output from outside workspace. In particular asserts that there are newlines between diffs, and no overlaps''' 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)
def test_rosinstall_abort_changes(self): cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.directory, self.simple_rosinstall]) self.assertTrue(rosinstall_main(cmd)) cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.directory, self.simple_changed_uri_rosinstall, "--abort-changed-uri", "-n"]) try: rosinstall_main(cmd) self.fail("expected exception") except MultiProjectException: pass
def test_multi_status_rosinstall_inside(self): """Test rosinstall status output when run inside workspace. In particular asserts that there are newlines between statuses, and no overlaps""" directory = self.test_root_path + "/ws" cmd = ["rosinstall", ".", "--status"] os.chdir(directory) sys.stdout = output = StringIO() rosinstall_main(cmd) 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)
def test_rosinstall_backup_changes(self): cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.directory, self.simple_rosinstall]) self.assertTrue(rosinstall_main(cmd)) directory1 = tempfile.mkdtemp() self.directories["backup1"] = directory1 cmd = copy.copy(self.rosinstall_fn) cmd.extend([ self.directory, self.simple_changed_uri_rosinstall, "--backup-changed-uri=%s" % directory1 ]) self.assertTrue(rosinstall_main(cmd)) self.assertEqual(len(os.listdir(directory1)), 1)
def test_multi_status_rosinstall_inside(self): """Test rosinstall status output when run inside workspace. In particular asserts that there are newlines between statuses, and no overlaps""" directory = self.test_root_path + "/ws" cmd = ["rosinstall", ".", "--status"] os.chdir(directory) sys.stdout = output = StringIO() rosinstall_main(cmd) 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)
def test_rosinstall_abort_changes(self): cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.directory, self.simple_rosinstall]) self.assertTrue(rosinstall_main(cmd)) cmd = copy.copy(self.rosinstall_fn) cmd.extend([ self.directory, self.simple_changed_uri_rosinstall, "--abort-changed-uri", "-n" ]) try: rosinstall_main(cmd) self.fail("expected exception") except MultiProjectException: pass
def test_source(self): """checkout into temp dir and test setup files""" cmd = copy.copy(self.rosinstall_fn) cmd.extend([ '-j8', self.directory, "http://packages.ros.org/cgi-bin/gen_rosinstall.py?rosdistro=electric&variant=ros-base&overlay=no" ]) 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_comm"))) self.assertTrue( os.path.exists(os.path.join(self.directory, "setup.sh"))) self.assertTrue( os.path.exists(os.path.join(self.directory, "setup.bash"))) 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_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_local_fuerte_catkin(self): distrodir = '/opt/ros/fuerte' cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.directory, distrodir, '--catkin']) self.assertTrue(rosinstall_main(cmd)) self.assertTrue( os.path.exists(os.path.join(self.directory, 'CMakeLists.txt')))
def test_local_cturtle(self): distrodir = '/opt/ros/cturtle' cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.directory, distrodir]) self.assertTrue(rosinstall_main(cmd)) 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_local_fuerte(self): distrodir = '/opt/ros/fuerte' cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.directory, distrodir]) self.assertTrue(rosinstall_main(cmd)) 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')) p = subprocess.Popen("bash -c 'set -e; . %s'" % os.path.join(self.directory, 'setup.bash'), shell=True, stdout=subprocess.PIPE, env=self.new_environ) output = p.communicate() self.assertEqual(0, p.returncode, (output, p.returncode)) p = subprocess.Popen("bash -c '. %s; echo $ROS_ROOT'" % os.path.join(self.directory, 'setup.bash'), shell=True, stdout=subprocess.PIPE, env=self.new_environ) output = p.communicate() self.assertEqual('/opt/ros/fuerte/share/ros', output[0].decode('UTF-8').rstrip('\n')) p = subprocess.Popen("sh -c '. %s; echo $ROS_ROOT'" % os.path.join(self.directory, 'setup.sh'), shell=True, stdout=subprocess.PIPE, env=self.new_environ) output = p.communicate() self.assertEqual('/opt/ros/fuerte/share/ros', output[0].decode('UTF-8').rstrip('\n'))
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)
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) # rosinstall 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 = ["rosinstall", "ws", "-n"] os.chdir(self.test_root_path) rosinstall_main(cmd) clone_path = os.path.join(self.local_path, "clone") modify_svn_repo(clone_path)
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 setUp(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) # setup a rosinstall env as base for further tests cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.directory, self.simple_rosinstall]) self.assertTrue(rosinstall_main(cmd)) self.new_directory = tempfile.mkdtemp() self.directories["new_ros_env"] = self.new_directory
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_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 setUpClass(self): AbstractSCMTest.setUpClass() remote_path = os.path.join(self.test_root_path, "remote") os.makedirs(remote_path) create_bzr_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- bzr: {local-name: clone, uri: %s}" % remote_path) cmd = ["rosinstall", "ws", "-n"] os.chdir(self.test_root_path) rosinstall_main(cmd) clone_path = os.path.join(self.local_path, "clone") modify_bzr_repo(clone_path)
def test_Rosinstall_ros_with_folder_and_setupfile(self): cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.new_directory, self.directory]) self.assertTrue(rosinstall_main(cmd)) stream = open(os.path.join(self.new_directory, '.rosinstall'), 'r') yamlsrc = yaml.load(stream) stream.close() self.assertEqual(3, len(yamlsrc)) self.assertEqual('other', list(yamlsrc[0].keys())[0]) self.assertEqual('setup-file', list(yamlsrc[1].keys())[0]) self.assertEqual('other', list(yamlsrc[2].keys())[0])
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_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_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_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_Rosinstall_rosinstall_file_input(self): """uses base rosinstall with ros and git repo""" cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.new_directory, self.directory]) 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('other', list(yamlsrc[1].keys())[0])
def test_source(self): """checkout into temp dir and test setup files""" cmd = copy.copy(self.rosinstall_fn) cmd.extend(['-j8', self.directory, 'http://ros.org/rosinstalls/cturtle_ros.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, "setup.sh"))) self.assertTrue(os.path.exists(os.path.join(self.directory, "setup.bash"))) subprocess.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_source(self): """checkout into temp dir and test setup files""" cmd = copy.copy(self.rosinstall_fn) cmd.extend(['-j8', self.directory, "http://packages.ros.org/cgi-bin/gen_rosinstall.py?rosdistro=electric&variant=ros-base&overlay=no"]) 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_comm"))) self.assertTrue(os.path.exists(os.path.join(self.directory, "setup.sh"))) self.assertTrue(os.path.exists(os.path.join(self.directory, "setup.bash"))) 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_install(self): cmd = copy.copy(self.rosinstall_fn) cmd.extend([self.directory, self.simple_tar_rosinstall]) self.assertTrue(rosinstall_main(cmd)) self.assertTrue(os.path.isdir(os.path.join(self.directory, "temptar"))) self.assertTrue(os.path.isfile(os.path.join(self.directory, ".rosinstall"))) stream = open(os.path.join(self.directory, '.rosinstall'), 'r') yamlsrc = yaml.load(stream) stream.close() self.assertEqual(2, len(yamlsrc)) self.assertEqual('other', list(yamlsrc[0].keys())[0]) self.assertEqual('tar', list(yamlsrc[1].keys())[0])
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_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_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 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_source(self): """checkout into temp dir and test setup files""" cmd = copy.copy(self.rosinstall_fn) url = "http://packages.ros.org/cgi-bin/gen_rosinstall.py?rosdistro=fuerte&variant=robot&overlay=no" self.simple_rosinstall = os.path.join(self.directory, "simple.rosinstall") response = urlopen(url) contents = response.read() with open(self.simple_rosinstall, 'wb') as fhand: fhand.write(contents) config = get_config(self.directory, [self.simple_rosinstall]) cmd.extend(['-j8', '--catkin', 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)) # fuerte core ros stacks are catkinized, installed via catkin workspace self.assertTrue(os.path.exists(os.path.join(self.directory, "common"))) self.assertTrue( os.path.exists(os.path.join(self.directory, "dynamic_reconfigure"))) self.assertTrue( os.path.exists(os.path.join(self.directory, "CMakeLists.txt")))