00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 import roslib; roslib.load_manifest('test_roscreate')
00033
00034 import os
00035 import sys
00036 import unittest
00037
00038 class RoscreateStackTest(unittest.TestCase):
00039
00040 def test_command_line(self):
00041 from subprocess import Popen, PIPE
00042 from roslib.rosenv import get_ros_root
00043
00044 output = Popen(['roscreate-stack', get_ros_root(), '--show-deps'], stdout=PIPE, stderr=PIPE).communicate()
00045 self.assertEquals('', output[0].strip())
00046 self.assertEquals('', output[1].strip())
00047
00048
00049 d = roslib.packages.get_pkg_dir('test_roscreate')
00050 d = os.path.join(d, 'test', 'fake-pkg')
00051
00052 os.environ['ROS_PACKAGE_PATH'] = d
00053 stack1 = os.path.join(d, 'stack1')
00054 stack2 = os.path.join(d, 'stack2')
00055
00056 output = Popen(['roscreate-stack', stack1, '--show-deps'], stdout=PIPE, stderr=PIPE).communicate()
00057 self.assertEquals('<depend stack="ros"/> <!-- roslib -->', output[0].strip())
00058 self.assertEquals('', output[1].strip())
00059
00060 output = Popen(['roscreate-stack', stack2, '--show-deps'], stdout=PIPE, stderr=PIPE).communicate()
00061 self.assert_('<depend stack="ros"/>' in output[0], output[0])
00062 self.assert_('<depend stack="stack1"/>' in output[0], output[0])
00063 self.assertEquals(2, len(output[0].strip().split('\n')))
00064 self.assertEquals('', output[1].strip())
00065
00066 def test_compute_stack_depends_and_licenses(self):
00067
00068
00069
00070
00071 import roslib.packages
00072 import roslib.stacks
00073 from roscreate.roscreatestack import compute_stack_depends_and_licenses
00074
00075 d = roslib.packages.get_pkg_dir('test_roscreate')
00076 d = os.path.join(d, 'test', 'fake-pkg')
00077
00078 os.environ['ROS_PACKAGE_PATH'] = d
00079 stack1 = os.path.join(d, 'stack1')
00080 stack2 = os.path.join(d, 'stack2')
00081
00082
00083 depends, licenses = compute_stack_depends_and_licenses(stack1)
00084 self.assertEquals(['ros'], depends.keys())
00085 self.assertEquals(['roslib'], depends['ros'])
00086 self.assertEquals(set(['BSD']), licenses)
00087
00088 d2, licenses = compute_stack_depends_and_licenses(stack2)
00089 self.assertEquals(set(['ros', 'stack1']), set(d2.keys()))
00090 self.assertEquals(['depends_roslib'], d2['stack1'])
00091 self.assertEquals(set(['BSD']), licenses)
00092
00093
00094
00095 depends, licenses = compute_stack_depends_and_licenses(os.environ['ROS_ROOT'])
00096 self.assertEquals({}, depends)
00097 self.assert_('BSD' in licenses)
00098
00099
00100
00101 if __name__ == '__main__':
00102 import rosunit
00103 rosunit.unitrun('test_roscreate', 'test_roscreate_stack', RoscreateStackTest, coverage_packages=['roscreate.roscreatestack'])
00104