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
00033
00034
00035
00036 PKG = 'test_roslaunch'
00037 NAME = 'test_version'
00038
00039 import roslib; roslib.load_manifest(PKG)
00040
00041 import roslib.stacks
00042
00043 import os
00044 import sys
00045 import unittest
00046 import re
00047
00048 def get_ros_comm_version():
00049 d = roslib.stacks.get_stack_dir('ros_comm')
00050 cmake_p = os.path.join(d, 'CMakeLists.txt')
00051 with open(cmake_p) as f:
00052 text = f.read()
00053 for l in text.split('\n'):
00054 if l.strip().startswith('rosbuild_make_distribution'):
00055 x_re = re.compile(r'[()]')
00056 lsplit = x_re.split(l.strip())
00057 if len(lsplit) < 2:
00058 raise Exception("couldn't find version number in CMakeLists.txt:\n\n%s"%l)
00059 return lsplit[1]
00060 raise Exception("could not locate version number in stack CMakeLists.txt")
00061
00062 class TestCoreVersion(unittest.TestCase):
00063
00064 def test_version(self):
00065 import roslib.packages
00066 import roslaunch.config
00067 import roslaunch.xmlloader
00068
00069
00070 rosversion = get_ros_comm_version()
00071
00072 loader = roslaunch.xmlloader.XmlLoader()
00073 config = roslaunch.config.ROSLaunchConfig()
00074 d = roslib.packages.get_pkg_dir('roslaunch')
00075 filename = os.path.join(d, 'roscore.xml')
00076 loader.load(filename, config)
00077 core_version = config.params['/rosversion'].value
00078
00079 self.assertEquals(rosversion, core_version)
00080
00081 if __name__ == '__main__':
00082 import rostest
00083 rostest.unitrun('test_roslaunch', NAME, TestCoreVersion, coverage_packages=[])
00084