diff --git a/test/test_roslib/CMakeLists.txt b/test/test_roslib/CMakeLists.txt
index fb4d3b1b..b8ed9dc3 100644
--- a/test/test_roslib/CMakeLists.txt
+++ b/test/test_roslib/CMakeLists.txt
@@ -3,19 +3,6 @@ find_package(catkin)
find_package(Boost COMPONENTS thread)
find_package(ROS COMPONENTS roslib)
-add_pyunit(test/test_roslib.py)
-add_pyunit(test/test_roslib_exceptions.py)
-add_pyunit(test/test_roslib_manifest.py)
-add_pyunit(test/test_roslib_manifestlib.py)
-add_pyunit(test/test_roslib_names.py)
-add_pyunit(test/test_roslib_packages.py)
-add_pyunit(test/test_roslib_params.py)
-add_pyunit(test/test_roslib_rosenv.py)
-add_pyunit(test/test_roslib_rospack.py)
-#add_pyunit(test/test_roslib_scriptutil.py)
-add_pyunit(test/test_roslib_stacks.py)
-add_pyunit(test/test_roslib_stack_manifest.py)
-
#integration tests
include_directories(${Boost_INCLUDE_DIRS} ${ROS_INCLUDE_DIRS})
diff --git a/test/test_roslib/test/fake_node.py b/test/test_roslib/test/fake_node.py
deleted file mode 100755
index 0e302153..00000000
--- a/test/test_roslib/test/fake_node.py
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/usr/bin/env python
-# this node only exists to test find_node functionality
-
-print "hello"
diff --git a/test/test_roslib/test/test_roslib.py b/test/test_roslib/test/test_roslib.py
deleted file mode 100644
index a6f1b2ff..00000000
--- a/test/test_roslib/test/test_roslib.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2009, Willow Garage, Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Willow Garage, Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-import roslib; roslib.load_manifest('test_roslib')
-
-import os
-import struct
-import sys
-import unittest
-
-import rosunit
-
-class RoslibTest(unittest.TestCase):
-
- def test_load_manifest(self):
- # this is a bit of a noop as it's a prerequisite of running with rosunit
- import roslib
- roslib.load_manifest('test_roslib')
-
- def test_interactive(self):
- import roslib
- import roslib.scriptutil
-
- # make sure that it's part of high-level API
- self.failIf(roslib.is_interactive(), "interactive should be false by default")
- for v in [True, False]:
- roslib.set_interactive(v)
- self.assertEquals(v, roslib.is_interactive())
- # roslib.scriptutil seems to be on its way out
- #self.assertEquals(v, roslib.scriptutil.is_interactive())
-
-if __name__ == '__main__':
- rosunit.unitrun('test_roslib', 'test_roslib_module', RoslibTest, coverage_packages=['roslib'])
-
diff --git a/test/test_roslib/test/test_roslib_exceptions.py b/test/test_roslib/test/test_roslib_exceptions.py
deleted file mode 100644
index fafe8805..00000000
--- a/test/test_roslib/test/test_roslib_exceptions.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2009, Willow Garage, Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Willow Garage, Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-import roslib; roslib.load_manifest('test_roslib')
-
-import os
-import struct
-import sys
-import unittest
-
-import rosunit
-
-class RoslibExceptionsTest(unittest.TestCase):
-
- def test_exceptions(self):
- from roslib.exceptions import ROSLibException
- self.assert_(isinstance(ROSLibException(), Exception))
-
-if __name__ == '__main__':
- rosunit.unitrun('test_roslib', 'test_exceptions', RoslibExceptionsTest, coverage_packages=['roslib.exceptions'])
-
diff --git a/test/test_roslib/test/test_roslib_manifest.py b/test/test_roslib/test/test_roslib_manifest.py
deleted file mode 100644
index 739d137d..00000000
--- a/test/test_roslib/test/test_roslib_manifest.py
+++ /dev/null
@@ -1,178 +0,0 @@
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2009, Willow Garage, Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Willow Garage, Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-import roslib; roslib.load_manifest('test_roslib')
-
-import os
-import struct
-import sys
-import unittest
-
-import rosunit
-
-class RoslibManifestTest(unittest.TestCase):
-
- def test_ManifestException(self):
- from roslib.manifest import ManifestException
- self.assert_(isinstance(ManifestException(), Exception))
-
- def test_Depend(self):
- from roslib.manifestlib import Depend, ManifestException
- for bad in [None, '']:
- try:
- Depend(bad)
- self.fail("should have failed on [%s]"%bad)
- except ValueError: pass
-
- d = Depend('roslib')
- self.assertEquals('roslib', str(d))
- self.assertEquals('roslib', repr(d))
-
- self.assertEquals('',d.xml())
- self.assertEquals(d, Depend('roslib'))
- self.assertNotEquals(d, Depend('roslib2'))
- self.assertNotEquals(d, 1)
-
- def test_ROSDep(self):
- from roslib.manifest import ROSDep, ManifestException
- for bad in [None, '']:
- try:
- rd = ROSDep(bad)
- self.fail("should have failed on [%s]"%bad)
- except ValueError: pass
-
- rd = ROSDep('python')
- self.assertEquals('',rd.xml())
-
- def test_VersionControl(self):
- from roslib.manifest import VersionControl, ManifestException
- ros_svn = 'https://ros.svn.sf.net/svnroot'
-
- bad = [
- (None, ros_svn),
- ]
- for type_, url in bad:
- try:
- VersionControl(type_,url)
- self.fail("should have failed on [%s] [%s]"%(type_, url))
- except ValueError: pass
-
- tests = [
- ('svn', ros_svn, ''%ros_svn),
- ('cvs', None, ''),
- ]
- for type_, url, xml in tests:
- vc = VersionControl(type_, url)
- self.assertEquals(type_, vc.type)
- self.assertEquals(url, vc.url)
- self.assertEquals(xml, vc.xml())
-
- def _subtest_parse_example1(self, m):
- from roslib.manifest import Manifest
- self.assert_(isinstance(m, Manifest))
- self.assertEquals("a brief description", m.brief)
- self.assertEquals("Line 1\nLine 2", m.description.strip())
- self.assertEquals("The authors\ngo here", m.author.strip())
- self.assertEquals("Public Domain\nwith other stuff", m.license.strip())
- self.assertEquals("http://pr.willowgarage.com/package/", m.url)
- self.assertEquals("http://www.willowgarage.com/files/willowgarage/robot10.jpg", m.logo)
- dpkgs = [d.package for d in m.depends]
- self.assertEquals(set(['pkgname', 'common']), set(dpkgs))
- rdpkgs = [d.name for d in m.rosdeps]
- self.assertEquals(set(['python', 'bar', 'baz']), set(rdpkgs))
-
- def test_parse_example1_file(self):
- from roslib.manifest import parse_file, Manifest
- p = os.path.join(roslib.packages.get_pkg_dir('test_roslib'), 'test', 'manifest_tests', 'example1.xml')
- self._subtest_parse_example1(parse_file(p))
-
- def test_parse_example1_string(self):
- from roslib.manifest import parse, Manifest
- self._subtest_parse_example1(parse(EXAMPLE1))
-
- def test_Manifest_str(self):
- # just make sure it doesn't crash
- from roslib.manifest import parse
- str(parse(EXAMPLE1))
-
- def test_Manifest_xml(self):
- from roslib.manifest import parse
- m = parse(EXAMPLE1)
- self._subtest_parse_example1(m)
- # verify roundtrip
- m2 = parse(m.xml())
- self._subtest_parse_example1(m2)
-
-
- def test_parse_bad_file(self):
- from roslib.manifest import parse_file, Manifest
- # have to import from ManifestException due to weirdness when run in --cov mode
- from roslib.manifestlib import ManifestException
- my_dir = roslib.packages.get_pkg_dir('test_roslib')
- base_p = os.path.join(my_dir, 'test', 'manifest_tests')
- for b in ['bad1.xml', 'bad2.xml', 'bad3.xml']:
- p = os.path.join(base_p, b)
- try:
- parse_file(p)
- self.fail("parse should have failed on bad manifest")
- except ManifestException, e:
- print str(e)
- self.assert_(b in str(e), "file name should be in error message: %s"%(str(e)))
-
-EXAMPLE1 = """
- Line 1
-Line 2
-
- The authors
-go here
- Public Domain
-with other stuff
- http://pr.willowgarage.com/package/
- http://www.willowgarage.com/files/willowgarage/robot10.jpg
-
-
-
-
-
-
-
-
-
-
-
-
-"""
-
-
-
-if __name__ == '__main__':
- rosunit.unitrun('test_roslib', 'test_manifest', RoslibManifestTest, coverage_packages=['roslib.manifest', 'roslib.manifestlib'])
-
diff --git a/test/test_roslib/test/test_roslib_manifestlib.py b/test/test_roslib/test/test_roslib_manifestlib.py
deleted file mode 100644
index fec65eac..00000000
--- a/test/test_roslib/test/test_roslib_manifestlib.py
+++ /dev/null
@@ -1,308 +0,0 @@
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2009, Willow Garage, Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Willow Garage, Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-import roslib; roslib.load_manifest('test_roslib')
-
-import os
-import struct
-import sys
-import unittest
-
-import rosunit
-
-class RoslibManifestlibTest(unittest.TestCase):
-
- def test_ManifestException(self):
- from roslib.manifestlib import ManifestException
- self.assert_(isinstance(ManifestException(), Exception))
-
- def test_Platform(self):
- from roslib.manifestlib import Platform, ManifestException
- for bad in [None, '']:
- try:
- Platform(bad, '1')
- self.fail("should have failed on [%s]"%bad)
- except ValueError: pass
- try:
- Platform('ubuntu', bad)
- self.fail("should have failed on [%s]"%bad)
- except ValueError: pass
-
- p = Platform('ubuntu', '8.04')
- self.assertEquals('ubuntu 8.04', str(p))
- self.assertEquals('ubuntu 8.04', repr(p))
-
- self.assertEquals('',p.xml())
- self.assertEquals(p, Platform('ubuntu', '8.04'))
- self.assertEquals(p, Platform('ubuntu', '8.04', notes=None))
- self.assertNotEquals(p, Platform('ubuntu', '8.04', 'some notes'))
- self.assertNotEquals(p, 'foo')
- self.assertNotEquals(p, 1)
-
- # note: probably actually "osx"
- p = Platform('OS X', '10.6', 'macports')
- self.assertEquals('OS X 10.6', str(p))
- self.assertEquals('OS X 10.6', repr(p))
-
- self.assertEquals('',p.xml())
- self.assertEquals(p, p)
- self.assertEquals(p, Platform('OS X', '10.6', 'macports'))
- self.assertNotEquals(p, Platform('OS X', '10.6'))
- self.assertNotEquals(p, 'foo')
- self.assertNotEquals(p, 1)
-
-
- def test_Depend(self):
- from roslib.manifestlib import Depend, StackDepend, ManifestException
- for bad in [None, '']:
- try:
- Depend(bad)
- self.fail("should have failed on [%s]"%bad)
- except ValueError: pass
-
- d = Depend('roslib')
- self.assertEquals('roslib', str(d))
- self.assertEquals('roslib', repr(d))
-
- self.assertEquals('',d.xml())
- self.assertEquals(d, Depend('roslib'))
- self.assertNotEquals(d, StackDepend('roslib'))
- self.assertNotEquals(d, Depend('roslib2'))
- self.assertNotEquals(d, 1)
-
- def test_StackDepend(self):
- from roslib.manifestlib import Depend, StackDepend, ManifestException
- for bad in [None, '']:
- try:
- StackDepend(bad)
- self.fail("should have failed on [%s]"%bad)
- except ValueError: pass
-
- d = StackDepend('common')
- self.assertEquals('common', str(d))
- self.assertEquals('common', repr(d))
-
- self.assertEquals('',d.xml())
- self.assertEquals(d, StackDepend('common'))
- self.assertNotEquals(d, Depend('common'))
- self.assertNotEquals(d, StackDepend('common2'))
- self.assertNotEquals(d, 1)
-
- def test_ROSDep(self):
- from roslib.manifestlib import ROSDep, ManifestException
- for bad in [None, '']:
- try:
- rd = ROSDep(bad)
- self.fail("should have failed on [%s]"%bad)
- except ValueError: pass
-
- rd = ROSDep('python')
- self.assertEquals('',rd.xml())
-
- def test_VersionControl(self):
- from roslib.manifestlib import VersionControl, ManifestException
- ros_svn = 'https://ros.svn.sf.net/svnroot'
-
- bad = [
- (None, ros_svn),
- ]
- for type_, url in bad:
- try:
- VersionControl(type_,url)
- self.fail("should have failed on [%s] [%s]"%(type_, url))
- except ValueError: pass
-
- tests = [
- ('svn', ros_svn, ''%ros_svn),
- ('cvs', None, ''),
- ]
- for type_, url, xml in tests:
- vc = VersionControl(type_, url)
- self.assertEquals(type_, vc.type)
- self.assertEquals(url, vc.url)
- self.assertEquals(xml, vc.xml())
-
- def _subtest_parse_example1(self, m):
- from roslib.manifestlib import _Manifest
- self.assert_(isinstance(m, _Manifest))
- self.assertEquals("a brief description", m.brief)
- self.assertEquals("Line 1\nLine 2", m.description.strip())
- self.assertEquals("The authors\ngo here", m.author.strip())
- self.assertEquals("Public Domain\nwith other stuff", m.license.strip())
- self.assertEquals("http://pr.willowgarage.com/package/", m.url)
- self.assertEquals("http://www.willowgarage.com/files/willowgarage/robot10.jpg", m.logo)
- dpkgs = [d.package for d in m.depends]
- self.assertEquals(set(['pkgname', 'common']), set(dpkgs))
- rdpkgs = [d.name for d in m.rosdeps]
- self.assertEquals(set(['python', 'bar', 'baz']), set(rdpkgs))
- for p in m.platforms:
- if p.os == 'ubuntu':
- self.assertEquals("8.04", p.version)
- self.assertEquals('', p.notes)
- elif p.os == 'OS X':
- self.assertEquals("10.6", p.version)
- self.assertEquals("macports", p.notes)
- else:
- self.fail("unknown platform "+str(p))
-
- def _subtest_parse_stack_example1(self, m):
- from roslib.manifestlib import _Manifest
- self.assert_(isinstance(m, _Manifest))
- self.assertEquals('stack', m._type)
- self.assertEquals("a brief description", m.brief)
- self.assertEquals("Line 1\nLine 2", m.description.strip())
- self.assertEquals("The authors\ngo here", m.author.strip())
- self.assertEquals("Public Domain\nwith other stuff", m.license.strip())
- self.assertEquals("http://ros.org/stack/", m.url)
- self.assertEquals("http://www.willowgarage.com/files/willowgarage/robot10.jpg", m.logo)
- dpkgs = [d.stack for d in m.depends]
- self.assertEquals(set(['stackname', 'common']), set(dpkgs))
- self.assertEquals([], m.rosdeps)
- self.assertEquals([], m.exports)
-
- def _subtest_parse_stack_version(self, m):
- self.assertEquals("1.2.3", m.version)
-
- def test_parse_example1_file(self):
- from roslib.manifestlib import parse_file, _Manifest
- p = os.path.join(roslib.packages.get_pkg_dir('test_roslib'), 'test', 'manifest_tests', 'example1.xml')
- self._subtest_parse_example1(parse_file(_Manifest(), p))
-
- p = os.path.join(roslib.packages.get_pkg_dir('test_roslib'), 'test', 'manifest_tests', 'stack_example1.xml')
- self._subtest_parse_stack_example1(parse_file(_Manifest('stack'), p))
-
- p = os.path.join(roslib.packages.get_pkg_dir('test_roslib'), 'test', 'manifest_tests', 'stack_version.xml')
- self._subtest_parse_stack_version(parse_file(_Manifest('stack'), p))
-
- def test_parse_example1_string(self):
- from roslib.manifestlib import parse, _Manifest
- self._subtest_parse_example1(parse(_Manifest(), EXAMPLE1))
- self._subtest_parse_stack_example1(parse(_Manifest('stack'), STACK_EXAMPLE1))
-
- def test__Manifest(self):
- from roslib.manifestlib import _Manifest
- m = _Manifest()
- # check defaults
- self.assertEquals('package', m._type)
- m = _Manifest('stack')
- self.assertEquals('stack', m._type)
-
- def test_Manifest_str(self):
- # just make sure it doesn't crash
- from roslib.manifestlib import parse, _Manifest
- str(parse(_Manifest(), EXAMPLE1))
-
- def test_Manifest_xml(self):
- from roslib.manifestlib import parse, _Manifest
- m = _Manifest()
- parse(m, EXAMPLE1)
- self._subtest_parse_example1(m)
- # verify roundtrip
- m2 = _Manifest()
- parse(m2, m.xml())
- self._subtest_parse_example1(m2)
-
- # bad file examples should be more like the roslaunch tests where there is just 1 thing wrong
- def test_parse_bad_file(self):
- from roslib.manifestlib import parse_file, _Manifest, ManifestException
- my_dir = roslib.packages.get_pkg_dir('test_roslib')
- base_p = os.path.join(my_dir, 'test', 'manifest_tests')
- m = _Manifest()
- for b in ['bad1.xml', 'bad2.xml', 'bad3.xml']:
- p = os.path.join(base_p, b)
- try:
- parse_file(m, p)
- self.fail("parse should have failed on bad manifest")
- except ManifestException, e:
- print str(e)
- self.assert_(b in str(e), "file name should be in error message [%s]"%(str(e)))
-
-EXAMPLE1 = """
- Line 1
-Line 2
-
- The authors
-go here
- Public Domain
-with other stuff
- http://pr.willowgarage.com/package/
- http://www.willowgarage.com/files/willowgarage/robot10.jpg
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-"""
-
-STACK_EXAMPLE1 = """
- Line 1
-Line 2
-
- The authors
-go here
- Public Domain
-with other stuff
- http://ros.org/stack/
- http://www.willowgarage.com/files/willowgarage/robot10.jpg
-
-
-"""
-
-STACK_INVALID1 = """
- Line 1
- The authors
- Public Domain
-
-"""
-
-STACK_INVALID2 = """
- Line 1
- The authors
- Public Domain
-
-
-
-
-"""
-
-
-if __name__ == '__main__':
- rosunit.unitrun('test_roslib', 'test_manifest', RoslibManifestlibTest, coverage_packages=['roslib.manifestlib'])
-
diff --git a/test/test_roslib/test/test_roslib_names.py b/test/test_roslib/test/test_roslib_names.py
deleted file mode 100644
index b655fd86..00000000
--- a/test/test_roslib/test/test_roslib_names.py
+++ /dev/null
@@ -1,358 +0,0 @@
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2009, Willow Garage, Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Willow Garage, Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-import roslib; roslib.load_manifest('test_roslib')
-
-import os
-import sys
-import unittest
-
-import roslib.names
-import rosunit
-
-class NamesTest(unittest.TestCase):
-
- def test_get_ros_namespace(self):
- if 'ROS_NAMESPACE' in os.environ:
- rosns = os.environ['ROS_NAMESPACE']
- del os.environ['ROS_NAMESPACE']
- else:
- rosns = None
- sysargv = sys.argv
-
- try:
- sys.argv = []
- self.assertEquals('/', roslib.names.get_ros_namespace())
- self.assertEquals('/', roslib.names.get_ros_namespace(argv=[]))
- self.assertEquals('/', roslib.names.get_ros_namespace(env={}))
- self.assertEquals('/', roslib.names.get_ros_namespace(env={}, argv=[]))
-
- os.environ['ROS_NAMESPACE'] = 'unresolved'
- self.assertEquals('/unresolved/', roslib.names.get_ros_namespace())
- self.assertEquals('/unresolved/', roslib.names.get_ros_namespace(env={'ROS_NAMESPACE': 'unresolved'}))
- sys.argv = ['foo', '__ns:=unresolved_override']
- self.assertEquals('/unresolved_override/', roslib.names.get_ros_namespace(env={'ROS_NAMESPACE': 'unresolved'}))
- self.assertEquals('/override2/', roslib.names.get_ros_namespace(env={'ROS_NAMESPACE': 'unresolved'}, argv=['foo', '__ns:=override2']))
-
- sys.argv = []
- os.environ['ROS_NAMESPACE'] = '/resolved/'
- self.assertEquals('/resolved/', roslib.names.get_ros_namespace())
- self.assertEquals('/resolved/', roslib.names.get_ros_namespace(env={'ROS_NAMESPACE': '/resolved'}))
-
- del os.environ['ROS_NAMESPACE']
-
- sys.argv = ['foo', '__ns:=unresolved_ns']
- self.assertEquals('/unresolved_ns/', roslib.names.get_ros_namespace())
- self.assertEquals('/unresolved_ns2/', roslib.names.get_ros_namespace(argv=['foo', '__ns:=unresolved_ns2']))
- sys.argv = ['foo', '__ns:=/resolved_ns/']
- self.assertEquals('/resolved_ns/', roslib.names.get_ros_namespace())
- self.assertEquals('/resolved_ns2/', roslib.names.get_ros_namespace(argv=['foo', '__ns:=resolved_ns2']))
- finally:
- sys.argv = sysargv
-
- # restore
- if rosns:
- os.environ['ROS_NAMESPACE'] = rosns
-
- def test_make_global_ns(self):
- from roslib.names import make_global_ns
-
- for n in ['~foo']:
- try:
- make_global_ns(n)
- self.fail("make_global_ns should fail on %s"%n)
- except ValueError: pass
-
- self.assertEquals('/foo/', make_global_ns('foo'))
- self.assertEquals('/', make_global_ns(''))
- self.assertEquals('/foo/', make_global_ns('/foo'))
- self.assertEquals('/foo/', make_global_ns('/foo/'))
- self.assertEquals('/foo/bar/', make_global_ns('/foo/bar'))
- self.assertEquals('/foo/bar/', make_global_ns('/foo/bar/'))
-
- def test_make_caller_id(self):
- from roslib.names import make_caller_id
- if 'ROS_NAMESPACE' is os.environ:
- rosns = os.environ['ROS_NAMESPACE']
- del os.environ['ROS_NAMESPACE']
- else:
- rosns = None
-
- for n in ['~name']:
- try:
- make_caller_id('~name') # illegal
- self.fail("make_caller_id should fail on %s"%n)
- except ValueError: pass
-
- self.assertEquals('/node/', make_caller_id('node'))
- self.assertEquals('/bar/node/', make_caller_id('bar/node'))
- self.assertEquals('/bar/node/', make_caller_id('/bar/node'))
-
- os.environ['ROS_NAMESPACE'] = '/test/'
- self.assertEquals('/test/node/', make_caller_id('node'))
- self.assertEquals('/test/bar/node/', make_caller_id('bar/node'))
- self.assertEquals('/bar/node/', make_caller_id('/bar/node'))
-
- # restore
- if rosns:
- os.environ['ROS_NAMESPACE'] = rosns
-
-
- def test_is_global(self):
- try:
- roslib.names.is_global(None)
- self.fail("is_global should raise exception on invalid param")
- except: pass
- tests = ['/', '/global', '/global2']
- for t in tests:
- self.assert_(roslib.names.is_global(t))
- fails = ['', 'not_global', 'not/global']
- for t in fails:
- self.failIf(roslib.names.is_global(t))
-
- def test_is_private(self):
- try:
- roslib.names.is_private(None)
- self.fail("is_private should raise exception on invalid param")
- except: pass
- tests = ['~name', '~name/sub']
- for t in tests:
- self.assert_(roslib.names.is_private(t))
- fails = ['', 'not_private', 'not/private', 'not/~private', '/not/~private']
- for t in fails:
- self.failIf(roslib.names.is_private(t))
-
- def test_namespace(self):
- from roslib.names import namespace
- try:
- namespace(1)
- self.fail("1")
- except TypeError: pass
- try:
- namespace(None)
- self.fail("None")
- except ValueError: pass
- self.assertEquals('/', namespace(''))
- self.assertEquals('/', namespace('/'))
- self.assertEquals('/', namespace('/foo'))
- self.assertEquals('/', namespace('/foo/'))
- self.assertEquals('/foo/', namespace('/foo/bar'))
- self.assertEquals('/foo/', namespace('/foo/bar/'))
- self.assertEquals('/foo/bar/', namespace('/foo/bar/baz'))
- self.assertEquals('/foo/bar/', namespace('/foo/bar/baz/'))
-
- # unicode tests
- self.assertEquals(u'/', namespace(u''))
- self.assertEquals(u'/', namespace(u'/'))
- self.assertEquals(u'/foo/bar/', namespace(u'/foo/bar/baz/'))
-
- def test_nsjoin(self):
- from roslib.names import ns_join
-
- # private and global names cannot be joined
- self.assertEquals('~name', ns_join('/foo', '~name'))
- self.assertEquals('/name', ns_join('/foo', '/name'))
- self.assertEquals('~name', ns_join('~', '~name'))
- self.assertEquals('/name', ns_join('/', '/name'))
-
- # ns can be '~' or '/'
- self.assertEquals('~name', ns_join('~', 'name'))
- self.assertEquals('/name', ns_join('/', 'name'))
-
- self.assertEquals('/ns/name', ns_join('/ns', 'name'))
- self.assertEquals('/ns/name', ns_join('/ns/', 'name'))
- self.assertEquals('/ns/ns2/name', ns_join('/ns', 'ns2/name'))
- self.assertEquals('/ns/ns2/name', ns_join('/ns/', 'ns2/name'))
-
- # allow ns to be empty
- self.assertEquals('name', ns_join('', 'name'))
-
-
- def test_load_mappings(self):
- from roslib.names import load_mappings
- self.assertEquals({}, load_mappings([]))
- self.assertEquals({}, load_mappings(['foo']))
- self.assertEquals({}, load_mappings([':=']))
- self.assertEquals({}, load_mappings([':=:=']))
- self.assertEquals({}, load_mappings(['f:=']))
- self.assertEquals({}, load_mappings([':=b']))
- self.assertEquals({}, load_mappings(['foo:=bar:=baz']))
- # should ignore node param assignments
- self.assertEquals({}, load_mappings(['_foo:=bar']))
-
- self.assertEquals({'foo': 'bar'}, load_mappings(['foo:=bar']))
- # should allow double-underscore names
- self.assertEquals({'__foo': 'bar'}, load_mappings(['__foo:=bar']))
- self.assertEquals({'foo': 'bar'}, load_mappings(['./f', '-x', '--blah', 'foo:=bar']))
- self.assertEquals({'a': '1', 'b': '2', 'c': '3'}, load_mappings(['c:=3', 'c:=', ':=3', 'a:=1', 'b:=2']))
-
- def test_resource_name(self):
- from roslib.names import resource_name
- self.assertEquals('foo/bar', resource_name('foo', 'bar'))
- self.assertEquals('bar', resource_name('foo', 'bar', my_pkg='foo'))
- self.assertEquals('foo/bar', resource_name('foo', 'bar', my_pkg='bar'))
- self.assertEquals('foo/bar', resource_name('foo', 'bar', my_pkg=''))
- self.assertEquals('foo/bar', resource_name('foo', 'bar', my_pkg=None))
-
- def test_resource_name_base(self):
- from roslib.names import resource_name_base
- self.assertEquals('', resource_name_base(''))
- self.assertEquals('bar', resource_name_base('bar'))
- self.assertEquals('bar', resource_name_base('foo/bar'))
- self.assertEquals('bar', resource_name_base('/bar'))
- self.assertEquals('', resource_name_base('foo/'))
-
- def test_resource_name_package(self):
- from roslib.names import resource_name_package
- self.assertEquals(None, resource_name_package(''))
- self.assertEquals(None, resource_name_package('foo'))
- self.assertEquals('foo', resource_name_package('foo/'))
- self.assertEquals('foo', resource_name_package('foo/bar'))
-
- def test_package_resource_name(self):
- from roslib.names import package_resource_name
- self.assertEquals(('', ''), package_resource_name(''))
- self.assertEquals(('', 'foo'), package_resource_name('foo'))
- self.assertEquals(('foo', 'bar'), package_resource_name('foo/bar'))
- self.assertEquals(('foo', ''), package_resource_name('foo/'))
- try:
- # only allowed single separator
- package_resource_name("foo/bar/baz")
- self.fail("should have raised ValueError")
- except ValueError:
- pass
-
-
- def test_is_legal_resource_name(self):
- from roslib.names import is_legal_resource_name
- failures = [None, '', 'hello\n', '\t', 'foo++', 'foo-bar', '#foo',
- ' name', 'name ',
- '~name', '/name',
- '1name', 'foo\\']
- for f in failures:
- self.failIf(is_legal_resource_name(f), f)
- tests = ['f', 'f1', 'f_', 'foo', 'foo_bar', 'foo/bar', 'roslib/Log']
- for t in tests:
- self.assert_(is_legal_resource_name(t), t)
-
- def test_is_legal_name(self):
- from roslib.names import is_legal_name
- failures = [None,
- 'foo++', 'foo-bar', '#foo',
- 'hello\n', '\t', ' name', 'name ',
- 'f//b',
- '1name', 'foo\\']
- for f in failures:
- self.failIf(is_legal_name(f), f)
- tests = ['',
- 'f', 'f1', 'f_', 'f/', 'foo', 'foo_bar', 'foo/bar', 'foo/bar/baz',
- '~f', '~a/b/c',
- '~/f',
- '/a/b/c/d', '/']
- for t in tests:
- self.assert_(is_legal_name(t), "[%s]"%t)
-
- def test_is_legal_base_name(self):
- from roslib.names import is_legal_base_name
- failures = [None, '', 'hello\n', '\t', 'foo++', 'foo-bar', '#foo',
- 'f/', 'foo/bar', '/', '/a',
- 'f//b',
- '~f', '~a/b/c',
- ' name', 'name ',
- '1name', 'foo\\']
- for f in failures:
- self.failIf(is_legal_base_name(f), f)
- tests = ['f', 'f1', 'f_', 'foo', 'foo_bar']
- for t in tests:
- self.assert_(is_legal_base_name(t), "[%s]"%t)
-
- def test_is_legal_resource_base_name(self):
- from roslib.names import is_legal_resource_base_name
- failures = [None, '', 'hello\n', '\t', 'foo++', 'foo-bar', '#foo',
- 'f/', 'foo/bar', '/', '/a',
- 'f//b',
- '~f', '~a/b/c',
- '~/f',
- ' name', 'name ',
- '1name', 'foo\\']
- for f in failures:
- self.failIf(is_legal_resource_base_name(f), f)
- tests = ['f', 'f1', 'f_', 'foo', 'foo_bar']
- for t in tests:
- self.assert_(is_legal_resource_base_name(t), "[%s]"%t)
-
- def test_resolve_name(self):
- from roslib.names import resolve_name
- # TODO: test with remappings
- tests = [
- ('', '/', '/'),
- ('', '/node', '/'),
- ('', '/ns1/node', '/ns1/'),
-
- ('foo', '', '/foo'),
- ('foo/', '', '/foo'),
- ('/foo', '', '/foo'),
- ('/foo/', '', '/foo'),
- ('/foo', '/', '/foo'),
- ('/foo/', '/', '/foo'),
- ('/foo', '/bar', '/foo'),
- ('/foo/', '/bar', '/foo'),
-
- ('foo', '/ns1/ns2', '/ns1/foo'),
- ('foo', '/ns1/ns2/', '/ns1/foo'),
- ('foo', '/ns1/ns2/ns3/', '/ns1/ns2/foo'),
- ('foo/', '/ns1/ns2', '/ns1/foo'),
- ('/foo', '/ns1/ns2', '/foo'),
- ('foo/bar', '/ns1/ns2', '/ns1/foo/bar'),
- ('foo//bar', '/ns1/ns2', '/ns1/foo/bar'),
- ('foo/bar', '/ns1/ns2/ns3', '/ns1/ns2/foo/bar'),
- ('foo//bar//', '/ns1/ns2/ns3', '/ns1/ns2/foo/bar'),
-
- ('~foo', '/', '/foo'),
- ('~foo', '/node', '/node/foo'),
- ('~foo', '/ns1/ns2', '/ns1/ns2/foo'),
- ('~foo/', '/ns1/ns2', '/ns1/ns2/foo'),
- ('~foo/bar', '/ns1/ns2', '/ns1/ns2/foo/bar'),
-
- # #3044
- ('~/foo', '/', '/foo'),
- ('~/foo', '/node', '/node/foo'),
- ('~/foo', '/ns1/ns2', '/ns1/ns2/foo'),
- ('~/foo/', '/ns1/ns2', '/ns1/ns2/foo'),
- ('~/foo/bar', '/ns1/ns2', '/ns1/ns2/foo/bar'),
-
- ]
- for name, node_name, v in tests:
- self.assertEquals(v, resolve_name(name, node_name))
-
-if __name__ == '__main__':
- rosunit.unitrun('test_roslib', 'test_names', NamesTest, coverage_packages=['roslib.names'])
-
diff --git a/test/test_roslib/test/test_roslib_packages.py b/test/test_roslib/test/test_roslib_packages.py
deleted file mode 100644
index e39eae36..00000000
--- a/test/test_roslib/test/test_roslib_packages.py
+++ /dev/null
@@ -1,189 +0,0 @@
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2009, Willow Garage, Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Willow Garage, Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-import roslib; roslib.load_manifest('test_roslib')
-
-import os
-import struct
-import sys
-import unittest
-
-import roslib.rosenv
-import roslib.packages
-import rosunit
-
-
-class RoslibPackagesTest(unittest.TestCase):
-
- def test_list_pkgs_by_path(self):
- from roslib.packages import list_pkgs_by_path
- # regression test for bug found where list_pkgs_by_path returns empty package name if path is a package and path is a relpath
- d = roslib.packages.get_pkg_dir('test_roslib')
-
- os.chdir(d)
-
- self.assertEquals(['test_roslib'], list_pkgs_by_path('.'))
- self.assertEquals(set(['bar', 'foo']), set(list_pkgs_by_path(os.path.join('test', 'package_tests'))))
- self.assertEquals(set(['bar', 'foo']), set(list_pkgs_by_path(os.path.join('test', 'package_tests', 'p1'))))
- self.assertEquals(['foo'], list_pkgs_by_path(os.path.join('test', 'package_tests', 'p1', 'foo')))
-
- self.assertEquals([], list_pkgs_by_path(os.path.join('bin')))
-
-
- def test_find_node(self):
- import roslib.packages
- d = roslib.packages.get_pkg_dir('test_roslib')
- p = os.path.join(d, 'test', 'fake_node.py')
- self.assertEquals(p, roslib.packages.find_node('test_roslib', 'fake_node.py'))
-
- self.assertEquals(None, roslib.packages.find_node('test_roslib', 'not_a_node'))
-
- def test_get_pkg_dir(self):
- import roslib.packages
- import roslib.rospack
- path = roslib.rospack.rospackexec(['find', 'test_roslib'])
- self.assertEquals(path, roslib.packages.get_pkg_dir('test_roslib'))
- try:
- self.assertEquals(path, roslib.packages.get_pkg_dir('fake_test_roslib'))
- self.fail("should have raised")
- except roslib.packages.InvalidROSPkgException: pass
-
- def test_get_dir_pkg(self):
- import roslib.packages
- import roslib.rospack
- path = os.path.realpath(roslib.rospack.rospackexec(['find', 'test_roslib']))
-
- res = roslib.packages.get_dir_pkg(path)
- res = (os.path.realpath(res[0]), res[1])
- self.assertEquals((path, 'test_roslib'), res)
- res = roslib.packages.get_dir_pkg(os.path.join(path, 'test'))
- res = (os.path.realpath(res[0]), res[1])
- self.assertEquals((path, 'test_roslib'), res)
-
- # must fail on parent of test_roslib
- self.assertEquals((None, None), roslib.packages.get_dir_pkg(os.path.dirname(path)))
-
- def test_ROSPackages(self):
- from roslib.packages import ROSPackages
- rp = ROSPackages()
-
- try:
- rp.load_manifests('test_roslib')
- self.fail("should have raised")
- except TypeError:
- pass
-
- # DEPENDS1
- x = rp.depends1(['test_roslib'])
- self.assertEquals(['test_roslib'], x.keys())
- self.assertEquals(set(['roslib', 'rosunit']), set(x['test_roslib']))
- x = rp.depends1(['test_roscreate'])
- self.assertEquals(['test_roscreate'], x.keys())
- self.assertEquals(set(['roslib', 'rosunit', 'roscreate']), set(x['test_roscreate']))
- # uncache
- rp = ROSPackages()
- x = rp.depends1(['test_roslib', 'test_roscreate'])
- self.assertEquals(set(['test_roscreate', 'test_roslib']), set(x.keys()))
- self.assertEquals(set(['roslib', 'rosunit', 'roscreate']), set(x['test_roscreate']))
- self.assertEquals(set(['roslib', 'rosunit']), set(x['test_roslib']))
-
- # DEPENDS
- test_roslib_depends = ['roslib', 'rosunit']
- x = rp.depends(['test_roslib'])
- self.assertEquals(['test_roslib'], x.keys())
- s1 = set(test_roslib_depends)
- s2 = set(x['test_roslib'])
- self.assertEquals(s1, s2, s1^s2)
-
- # - null case for depends1 and depends
- no_depends = ['mk', 'rospack', 'rosbuild']
- for p in no_depends:
- self.assertEquals({p: []}, rp.depends1([p]))
- self.assertEquals({p: []}, rp.depends([p]))
- # uncache
- rp = ROSPackages()
- v = dict((p, []) for p in no_depends)
- self.assertEquals(v, rp.depends1(no_depends))
- # recache
- self.assertEquals(v, rp.depends1(no_depends))
-
-
- # ROSDEPS and ROSDEPS0
- roslib_rosdeps0 = ['python', 'python-yaml', 'boost']
- roslib_rosdeps = roslib_rosdeps0
- rosbuild_rosdeps = ['bzip2']
-
- rp = ROSPackages()
- # ROSDEPS0
- x = rp.rosdeps0(['mk'])
- self.assertEquals(['mk'], x.keys())
- self.assertEquals(set(), set(x['mk']))
-
- x = rp.rosdeps0(['roslib'])
- self.assertEquals(['roslib'], x.keys())
- self.assertEquals(set(roslib_rosdeps0), set(x['roslib']))
-
- x = rp.rosdeps0(['rosbuild'])
- self.assertEquals(['rosbuild'], x.keys())
- self.assertEquals(set(rosbuild_rosdeps), set(x['rosbuild']))
-
- # ROSDEPS
- p = 'rosunit'
- rosunit_rosdeps = set(roslib_rosdeps + ['gtest'])
- x = rp.rosdeps([p])
- self.assertEquals([p], x.keys())
- self.assertEquals(rosunit_rosdeps, set(x[p]))
- x = rp.rosdeps(['rosunit', 'mk'])
- self.assertEquals(set(['rosunit', 'mk']), set(x.keys()))
- self.assertEquals(rosunit_rosdeps, set(x['rosunit']))
- self.assertEquals([], x['mk'])
-
- rp = ROSPackages()
- no_rosdeps = ['mk', 'rospack']
- no_rosdeps0 = no_rosdeps + ['test_roslib']
- for p in no_rosdeps0:
- self.assertEquals({p: []}, rp.rosdeps0([p]))
- if p in no_rosdeps:
- self.assertEquals({p: []}, rp.rosdeps([p]))
- # uncache
- rp = ROSPackages()
- v = dict((p, []) for p in no_rosdeps)
- self.assertEquals(v, rp.rosdeps0(no_rosdeps))
- if p in no_rosdeps:
- self.assertEquals({p: []}, rp.rosdeps([p]))
- # recache
- self.assertEquals(v, rp.rosdeps0(no_rosdeps))
- if p in no_rosdeps:
- self.assertEquals({p: []}, rp.rosdeps([p]))
-
-if __name__ == '__main__':
- rosunit.unitrun('test_roslib', 'test_packages', RoslibPackagesTest, coverage_packages=['roslib.packages'])
-
diff --git a/test/test_roslib/test/test_roslib_params.py b/test/test_roslib/test/test_roslib_params.py
deleted file mode 100644
index d2cb11f7..00000000
--- a/test/test_roslib/test/test_roslib_params.py
+++ /dev/null
@@ -1,61 +0,0 @@
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2009, Willow Garage, Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Willow Garage, Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-import roslib; roslib.load_manifest('test_roslib')
-
-import os
-import sys
-import unittest
-
-import roslib.names
-import rosunit
-
-class ParamsTest(unittest.TestCase):
-
- def test_load_param_mappings(self):
- from roslib.params import load_command_line_node_params
- self.assertEquals({}, load_command_line_node_params([]))
- self.assertEquals({}, load_command_line_node_params(['foo']))
- self.assertEquals({}, load_command_line_node_params(['_foo']))
- self.assertEquals({}, load_command_line_node_params([':=']))
- self.assertEquals({}, load_command_line_node_params([':=:=']))
- self.assertEquals({}, load_command_line_node_params(['_f:=']))
- self.assertEquals({}, load_command_line_node_params([':=b']))
- self.assertEquals({}, load_command_line_node_params(['_foo:=_bar:=baz']))
-
- self.assertEquals({'foo': 'bar'}, load_command_line_node_params(['_foo:=bar']))
- self.assertEquals({'foo': 'bar'}, load_command_line_node_params(['./f', '-x', '--blah', '_foo:=bar']))
- self.assertEquals({'a': 'one', 'b': 2, 'c': 3.0, 'd':[1,2,3,4]}, load_command_line_node_params(['_c:=3.0', '_c:=', ':=3', '_a:=one', '_b:=2', '_d:=[1,2,3,4]']))
-
-
-if __name__ == '__main__':
- rosunit.unitrun('test_roslib', 'test_params', ParamsTest, coverage_packages=['roslib.params'])
-
diff --git a/test/test_roslib/test/test_roslib_rosenv.py b/test/test_roslib/test/test_roslib_rosenv.py
deleted file mode 100644
index 9d1c964a..00000000
--- a/test/test_roslib/test/test_roslib_rosenv.py
+++ /dev/null
@@ -1,156 +0,0 @@
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2009, Willow Garage, Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Willow Garage, Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-import roslib; roslib.load_manifest('test_roslib')
-
-import os
-import sys
-import unittest
-
-import roslib.rosenv
-import rosunit
-
-class EnvTest(unittest.TestCase):
-
- def test_get_ros_root(self):
- from roslib.rosenv import get_ros_root
- self.assertEquals(None, get_ros_root(required=False, env={}))
- self.assertEquals(None, get_ros_root(False, {}))
- try:
- get_ros_root(required=True, env={})
- self.fail("get_ros_root should have failed")
- except: pass
-
- env = {'ROS_ROOT': '/fake/path'}
- self.assertEquals('/fake/path', get_ros_root(required=False, env=env))
- try:
- get_ros_root(required=True, env=env)
- self.fail("get_ros_root should have failed")
- except: pass
-
- real_ros_root = get_ros_root(required=True)
-
- # make sure that ros root is a directory
- p = os.path.join(real_ros_root, 'Makefile')
- env = {'ROS_ROOT': p}
- self.assertEquals(p, get_ros_root(required=False, env=env))
- try:
- get_ros_root(required=True, env=env)
- self.fail("get_ros_root should have failed")
- except: pass
-
- def test_get_ros_package_path(self):
- from roslib.rosenv import get_ros_package_path
- self.assertEquals(None, get_ros_package_path(required=False, env={}))
- self.assertEquals(None, get_ros_package_path(False, {}))
- try:
- get_ros_package_path(required=True, env={})
- self.fail("get_ros_package_path should have raised")
- except: pass
- env = {'ROS_PACKAGE_PATH': ':'}
- self.assertEquals(':', get_ros_package_path(True, env=env))
- self.assertEquals(':', get_ros_package_path(False, env=env))
-
- # trip-wire tests. Cannot guarantee that ROS_PACKAGE_PATH is set
- # to valid value on test machine, just make sure logic doesn't crash
- self.assertEquals(os.environ.get('ROS_PACKAGE_PATH', None), get_ros_package_path(required=False))
-
- def test_get_ros_master_uri(self):
- from roslib.rosenv import get_master_uri
- self.assertEquals(None, get_master_uri(required=False, env={}))
- self.assertEquals(None, get_master_uri(False, {}))
- try:
- get_master_uri(required=True, env={})
- self.fail("get_ros_package_path should have raised")
- except: pass
- env = {'ROS_MASTER_URI': 'http://localhost:1234'}
- self.assertEquals('http://localhost:1234', get_master_uri(True, env=env))
- self.assertEquals('http://localhost:1234', get_master_uri(False, env=env))
-
- argv = ['__master:=http://localhost:5678']
- self.assertEquals('http://localhost:5678', get_master_uri(False, env=env, argv=argv))
-
- try:
- argv = ['__master:=http://localhost:5678:=http://localhost:1234']
- get_master_uri(required=False, env=env, argv=argv)
- self.fail("should have thrown")
- except roslib.rosenv.ROSEnvException: pass
-
- try:
- argv = ['__master:=']
- get_master_uri(False, env=env, argv=argv)
- self.fail("should have thrown")
- except roslib.rosenv.ROSEnvException: pass
-
- # make sure test works with os.environ
- self.assertEquals(os.environ.get('ROS_MASTER_URI', None), get_master_uri(required=False))
-
- def test_get_test_results_dir(self):
- from roslib.rosenv import get_ros_root, get_test_results_dir
- import tempfile, os
- base = tempfile.gettempdir()
- ros_test_results_dir = os.path.join(base, 'ros_test_results_dir')
- ros_home_dir = os.path.join(base, 'ros_home_dir')
- home_dir = os.path.expanduser('~')
-
- # ROS_TEST_RESULTS_DIR has precedence
- env = {'ROS_ROOT': get_ros_root(), 'ROS_TEST_RESULTS_DIR': ros_test_results_dir, 'ROS_HOME': ros_home_dir }
- self.assertEquals(ros_test_results_dir, get_test_results_dir(env=env))
-
- env = {'ROS_ROOT': get_ros_root(), 'ROS_HOME': ros_home_dir }
- self.assertEquals(os.path.join(ros_home_dir, 'test_results'), get_test_results_dir(env=env))
-
- env = {'ROS_ROOT': get_ros_root()}
- self.assertEquals(os.path.join(home_dir, '.ros', 'test_results'), get_test_results_dir(env=env))
-
- # test default assignment of env. Don't both checking return value as we would duplicate get_test_results_dir
- self.assert_(get_test_results_dir() is not None)
-
- def test_get_ros_home(self):
- from roslib.rosenv import get_ros_root, get_ros_home
- import tempfile, os
- base = tempfile.gettempdir()
- ros_home_dir = os.path.join(base, 'ros_home_dir')
- home_dir = os.path.expanduser('~')
-
- # ROS_HOME has precedence
- env = {'ROS_ROOT': get_ros_root(), 'ROS_HOME': ros_home_dir }
- self.assertEquals(ros_home_dir, get_ros_home(env=env))
-
- env = {'ROS_ROOT': get_ros_root()}
- self.assertEquals(os.path.join(home_dir, '.ros'), get_ros_home(env=env))
-
- # test default assignment of env. Don't both checking return value
- self.assert_(get_ros_home() is not None)
-
-if __name__ == '__main__':
- rosunit.unitrun('test_roslib', 'test_env', EnvTest, coverage_packages=['roslib.rosenv'])
-
diff --git a/test/test_roslib/test/test_roslib_rospack.py b/test/test_roslib/test/test_roslib_rospack.py
deleted file mode 100644
index 78f4062d..00000000
--- a/test/test_roslib/test/test_roslib_rospack.py
+++ /dev/null
@@ -1,66 +0,0 @@
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2009, Willow Garage, Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Willow Garage, Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-import roslib; roslib.load_manifest('test_roslib')
-
-import os
-import struct
-import sys
-import unittest
-
-import rosunit
-
-class RoslibRospackTest(unittest.TestCase):
-
- def test_rospack(self):
- from roslib.rospack import rospackexec, rospack_depends, rospack_depends_1,\
- rospack_depends_on, rospack_depends_on_1
-
- val = rospackexec(['list'])
- self.assertEquals(set(['roslib', 'rosunit']), set(rospack_depends('test_roslib')))
- self.assertEquals(set(['roslib', 'rosunit']), set(rospack_depends_1('test_roslib')))
- self.assertEquals(set(['roslib']), set(rospack_depends_1('rosclean')))
- self.assertEquals(set(['roslib']), set(rospack_depends('rosclean')))
-
- def test_rosstack(self):
- from roslib.rospack import rosstackexec, rosstack_depends, rosstack_depends_1,\
- rosstack_depends_on, rosstack_depends_on_1
- self.assertEquals(set([]), set(rosstack_depends('ros')))
- self.assertEquals(set([]), set(rosstack_depends_1('ros')))
-
- # can't actually test these w/o setting up stack environment, so just make sure they don't throw
- self.assert_(rosstack_depends_on('ros') is not None)
- self.assert_(rosstack_depends_on_1('ros') is not None)
-
-
-if __name__ == '__main__':
- rosunit.unitrun('test_roslib', 'test_rospack', RoslibRospackTest, coverage_packages=['roslib.rospack'])
-
diff --git a/test/test_roslib/test/test_roslib_stack_manifest.py b/test/test_roslib/test/test_roslib_stack_manifest.py
deleted file mode 100644
index c08ed6e3..00000000
--- a/test/test_roslib/test/test_roslib_stack_manifest.py
+++ /dev/null
@@ -1,127 +0,0 @@
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2009, Willow Garage, Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Willow Garage, Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-import roslib; roslib.load_manifest('test_roslib')
-
-import os
-import struct
-import sys
-import unittest
-
-import rosunit
-
-class RoslibStackManifestTest(unittest.TestCase):
-
- def _subtest_parse_stack_example1(self, m):
- from roslib.manifestlib import _Manifest
- self.assert_(isinstance(m, _Manifest))
- self.assertEquals('stack', m._type)
- self.assertEquals("a brief description", m.brief)
- self.assertEquals("Line 1\nLine 2", m.description.strip())
- self.assertEquals("The authors\ngo here", m.author.strip())
- self.assertEquals("Public Domain\nwith other stuff", m.license.strip())
- self.assertEquals("http://ros.org/stack/", m.url)
- self.assertEquals("http://www.willowgarage.com/files/willowgarage/robot10.jpg", m.logo)
- dpkgs = [d.stack for d in m.depends]
- self.assertEquals(set(['stackname', 'common']), set(dpkgs))
- self.assertEquals([], m.rosdeps)
- self.assertEquals([], m.exports)
-
- def _subtest_parse_stack_version(self, m):
- self.assertEquals("1.2.3", m.version)
-
- def test_parse_example1_file(self):
- from roslib.stack_manifest import parse_file, StackManifest
-
- p = os.path.join(roslib.packages.get_pkg_dir('test_roslib'), 'test', 'manifest_tests', 'stack_example1.xml')
- self._subtest_parse_stack_example1(parse_file(p))
-
- p = os.path.join(roslib.packages.get_pkg_dir('test_roslib'), 'test', 'manifest_tests', 'stack_version.xml')
- self._subtest_parse_stack_version(parse_file(p))
-
- def test_parse_example1_string(self):
- from roslib.manifestlib import parse, _Manifest
- self._subtest_parse_stack_example1(parse(_Manifest('stack'), STACK_EXAMPLE1))
-
- def test_StackManifest(self):
- from roslib.stack_manifest import StackManifest
- m = StackManifest()
- self.assertEquals('stack', m._type)
-
- def test_StackManifest_str(self):
- # just make sure it doesn't crash
- from roslib.stack_manifest import parse
- str(parse(STACK_EXAMPLE1))
-
- def test_StackManifest_xml(self):
- from roslib.stack_manifest import parse, StackManifest
- m = parse(STACK_EXAMPLE1)
- self._subtest_parse_stack_example1(m)
- # verify roundtrip
- m2 = parse(m.xml())
- self._subtest_parse_stack_example1(m2)
-
- # bad file examples should be more like the roslaunch tests where there is just 1 thing wrong
-STACK_EXAMPLE1 = """
- Line 1
-Line 2
-
- The authors
-go here
- Public Domain
-with other stuff
- http://ros.org/stack/
- http://www.willowgarage.com/files/willowgarage/robot10.jpg
-
-
-"""
-
-STACK_INVALID1 = """
- Line 1
- The authors
- Public Domain
-
-"""
-
-STACK_INVALID2 = """
- Line 1
- The authors
- Public Domain
-
-
-
-
-"""
-
-
-if __name__ == '__main__':
- rosunit.unitrun('test_roslib', 'test_stack_manifest', RoslibStackManifestTest, coverage_packages=['roslib.stack_manifest'])
-
diff --git a/test/test_roslib/test/test_roslib_stacks.py b/test/test_roslib/test/test_roslib_stacks.py
deleted file mode 100644
index f2c935f4..00000000
--- a/test/test_roslib/test/test_roslib_stacks.py
+++ /dev/null
@@ -1,256 +0,0 @@
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2009, Willow Garage, Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Willow Garage, Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-import roslib; roslib.load_manifest('test_roslib')
-
-import os
-import struct
-import sys
-import unittest
-
-import rospkg
-
-import rosunit
-
-class RoslibStacksTest(unittest.TestCase):
-
- def test_stack_of(self):
- import roslib.packages
- from roslib.stacks import stack_of
- self.assertEquals('ros', stack_of('test_roslib'))
- # due to caching, test twice
- self.assertEquals('ros', stack_of('test_roslib'))
- try:
- stack_of('fake_test_roslib')
- self.fail("should have failed")
- except roslib.packages.InvalidROSPkgException:
- pass
-
- # test unary
- test_dir = os.path.join(roslib.packages.get_pkg_dir('test_roslib'), 'test', 'stack_tests_unary')
- env = os.environ.copy()
- env['ROS_PACKAGE_PATH'] = test_dir
- for s in ['foo', 'bar']:
- self.assertEquals(s, stack_of(s, env=env))
-
- def test_list_stacks(self):
- from roslib.stacks import list_stacks
- l = list_stacks()
- self.assert_('ros' in l)
-
- # make sure it is equivalent to rosstack list
- from roslib.rospack import rosstackexec
- l2 = [x for x in rosstackexec(['list']).split('\n') if x]
- l2 = [x.split()[0] for x in l2]
- self.assertEquals(set(l), set(l2), set(l) ^ set(l2))
-
- # test with env
- test_dir = os.path.join(roslib.packages.get_pkg_dir('test_roslib'), 'test', 'stack_tests', 's1')
- env = os.environ.copy()
- env['ROS_PACKAGE_PATH'] = test_dir
- self.assertEquals(set(['ros', 'foo', 'bar']), set(list_stacks(env=env)))
-
-
- def test_list_stacks_by_path(self):
- from roslib.stacks import list_stacks_by_path
-
- # test with the ros stack
- rr = rospkg.get_ros_root()
- self.assertEquals(['ros'], list_stacks_by_path(rr))
- stacks = []
- self.assertEquals(['ros'], list_stacks_by_path(rr, stacks))
- self.assertEquals(['ros'], stacks)
- self.assertEquals(['ros'], list_stacks_by_path(rr, stacks))
-
- stacks.extend(['fake_stack', 'fake_stack2'])
- self.assertEquals(['ros', 'fake_stack', 'fake_stack2'], list_stacks_by_path(rr, stacks))
-
- cache = {}
- self.assertEquals(['ros'], list_stacks_by_path(rr, cache=cache))
- self.assertEquals({'ros': rr}, cache)
-
- # test with synthetic stacks
- test_dir = os.path.join(roslib.packages.get_pkg_dir('test_roslib'), 'test', 'stack_tests')
- self.assertEquals(set(['bar', 'foo']), set(list_stacks_by_path(test_dir)))
-
- test_dir = os.path.join(roslib.packages.get_pkg_dir('test_roslib'), 'test', 'stack_tests', 's1')
- self.assertEquals(set(['bar', 'foo']), set(list_stacks_by_path(test_dir)))
-
- test_dir = os.path.join(roslib.packages.get_pkg_dir('test_roslib'), 'test', 'stack_tests', 's1', 'bar')
- self.assertEquals(['bar'], list_stacks_by_path(test_dir))
-
- # test symlink following
-
- test_dir = os.path.join(roslib.packages.get_pkg_dir('test_roslib'), 'test', 'stack_tests2')
- self.assertEquals(set(['foo', 'bar']), set(list_stacks_by_path(test_dir)))
-
- def test_list_stacks_by_path_unary(self):
- from roslib.stacks import list_stacks_by_path
- # test with synthetic stacks
- test_dir = os.path.join(roslib.packages.get_pkg_dir('test_roslib'), 'test', 'stack_tests_unary')
- self.assertEquals(set(['bar', 'foo', 'baz']), set(list_stacks_by_path(test_dir)))
-
- def test_get_stack_dir_unary(self):
- # now manipulate the environment to test precedence
- # - save original RPP as we popen rosstack in other tests
- d = roslib.packages.get_pkg_dir('test_roslib')
- d = os.path.join(d, 'test', 'stack_tests_unary')
- s1_d = os.path.join(d, 's1')
- rpp = rospkg.get_ros_package_path()
- try:
- paths = [d]
- os.environ[rospkg.environment.ROS_PACKAGE_PATH] = os.pathsep.join(paths)
- self.assertEquals(os.path.join(s1_d, 'foo'), roslib.stacks.get_stack_dir('foo'))
- self.assertEquals(os.path.join(s1_d, 'bar'), roslib.stacks.get_stack_dir('bar'))
- self.assertEquals(os.path.join(s1_d, 'baz'), roslib.stacks.get_stack_dir('baz'))
- finally:
- #restore rpp
- if rpp is not None:
- os.environ[rospkg.environment.ROS_PACKAGE_PATH] = rpp
- else:
- del os.environ[rospkg.environment.ROS_PACKAGE_PATH]
-
- def test_get_stack_dir(self):
- import roslib.packages
- from roslib.stacks import get_stack_dir, InvalidROSStackException, list_stacks
- self.assertEquals(rospkg.get_ros_root(), get_stack_dir('ros'))
- try:
- get_stack_dir('non_existent')
- self.fail("should have raised")
- except roslib.stacks.InvalidROSStackException:
- pass
-
- # make sure it agrees with rosstack
- stacks = list_stacks()
- from roslib.rospack import rosstackexec
- for s in stacks:
- d1 = get_stack_dir(s)
- d2 = rosstackexec(['find', s])
- self.assertEquals(d1, d2, "%s vs %s"%(d1, d2))
-
- # now manipulate the environment to test precedence
- # - save original RPP as we popen rosstack in other tests
- rpp = os.environ.get(rospkg.environment.ROS_PACKAGE_PATH, None)
- try:
- d = roslib.packages.get_pkg_dir('test_roslib')
- d = os.path.join(d, 'test', 'stack_tests')
-
- # - s1/s2/s3
- print "s1/s2/s3"
- paths = [os.path.join(d, p) for p in ['s1', 's2', 's3']]
- os.environ[rospkg.environment.ROS_PACKAGE_PATH] = os.pathsep.join(paths)
- # - run multiple times to test caching
- for i in xrange(2):
- stacks = roslib.stacks.list_stacks()
- self.assert_('foo' in stacks)
- self.assert_('bar' in stacks)
-
- foo_p = os.path.join(d, 's1', 'foo')
- bar_p = os.path.join(d, 's1', 'bar')
- self.assertEquals(foo_p, roslib.stacks.get_stack_dir('foo'))
- self.assertEquals(bar_p, roslib.stacks.get_stack_dir('bar'))
-
- # - s2/s3/s1
- print "s2/s3/s1"
-
- paths = [os.path.join(d, p) for p in ['s2', 's3', 's1']]
- os.environ[rospkg.environment.ROS_PACKAGE_PATH] = os.pathsep.join(paths)
- stacks = roslib.stacks.list_stacks()
- self.assert_('foo' in stacks)
- self.assert_('bar' in stacks)
-
- foo_p = os.path.join(d, 's2', 'foo')
- bar_p = os.path.join(d, 's1', 'bar')
- self.assertEquals(foo_p, roslib.stacks.get_stack_dir('foo'))
- self.assertEquals(bar_p, roslib.stacks.get_stack_dir('bar'))
- finally:
- #restore rpp
- if rpp is not None:
- os.environ[rospkg.environment.ROS_PACKAGE_PATH] = rpp
- else:
- del os.environ[rospkg.environment.ROS_PACKAGE_PATH]
-
- def test_expand_to_packages_unary(self):
- # test unary
- test_dir = os.path.join(roslib.packages.get_pkg_dir('test_roslib'), 'test', 'stack_tests_unary')
-
- env = os.environ.copy()
- env[rospkg.environment.ROS_PACKAGE_PATH] = test_dir
-
- from roslib.stacks import expand_to_packages
- self.assertEquals((['foo'], []), expand_to_packages(['foo'], env=env))
- self.assertEquals((['foo', 'bar'], []), expand_to_packages(['foo', 'bar'], env=env))
-
- def test_expand_to_packages(self):
- from roslib.stacks import expand_to_packages
- try:
- # it's possible to accidentally pass in a sequence type
- # like a string and get weird results, so check that we
- # don't
- self.assertEquals(([], []), expand_to_packages('ros'))
- self.fail("expand_to_packages should only take in a list of strings")
- except ValueError: pass
-
- self.assertEquals(([], []), expand_to_packages([]))
- self.assertEquals((['rosmake', 'test_roslib', 'roslib'], []), expand_to_packages(['rosmake', 'test_roslib', 'roslib']))
- self.assertEquals(([], ['bogus_one', 'bogus_two']), expand_to_packages(['bogus_one', 'bogus_two']))
-
- self.assertEquals(([], ['bogus_one', 'bogus_two']), expand_to_packages(['bogus_one', 'bogus_two']))
-
- # TODO: setup directory tree so that this can be more precisely calculated
- valid, invalid = expand_to_packages(['ros', 'bogus_one'])
- self.assertEquals(['bogus_one'], invalid)
- check = ['rosbuild', 'rosunit', 'test_roslib']
- print valid
- for c in check:
- self.assert_(c in valid, "expected [%s] to be in ros expansion"%c)
-
- def test_get_stack_version(self):
- from roslib.stacks import get_stack_version
-
-
- test_dir = os.path.join(roslib.packages.get_pkg_dir('test_roslib'), 'test', 'stack_tests', 's1')
- env = os.environ.copy()
- env[rospkg.environment.ROS_PACKAGE_PATH] = test_dir
-
- # REP 109: stack.xml has precedence over CMakeLists.txt, version is whitespace stripped
- self.assertEquals('1.6.0-manifest', roslib.stacks.get_stack_version('foo', env=env))
- # REP 109: test fallback to CMakeLists.txt version
- self.assertEquals('1.5.0-cmake', roslib.stacks.get_stack_version('bar', env=env))
-
- if 0:
- test_dir = os.path.join(roslib.packages.get_pkg_dir('test_roslib'), 'test', 'stack_tests_unary')
- env = os.environ.copy()
- env[rospkg.environment.ROS_PACKAGE_PATH] = test_dir
-
-if __name__ == '__main__':
- rosunit.unitrun('test_roslib', 'test_stacks', RoslibStacksTest, coverage_packages=['roslib.stacks'])
-
diff --git a/test/test_roslib/test/test_roslib_substitution_args.py b/test/test_roslib/test/test_roslib_substitution_args.py
deleted file mode 100644
index dcc9ec1d..00000000
--- a/test/test_roslib/test/test_roslib_substitution_args.py
+++ /dev/null
@@ -1,170 +0,0 @@
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2009, Willow Garage, Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Willow Garage, Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-import roslib; roslib.load_manifest('test_roslib')
-
-import os
-import sys
-import unittest
-
-import rosunit
-
-class SubArgsTest(unittest.TestCase):
-
- def test__arg(self):
- import random
- from roslib.substitution_args import _arg, ArgException, SubstitutionException
-
- ctx = { 'arg': {
- 'foo': '12345',
- 'bar': 'hello world',
- 'baz': 'sim',
- 'empty': '',
- }
- }
-
- # test invalid
- try:
- _arg('$(arg)', 'arg', [], ctx)
- self.fail("should have thrown")
- except SubstitutionException:
- pass
-
- # test normal
- tests = [
- ('12345', ('$(arg foo)', 'arg foo', ['foo'], ctx)),
- ('', ('$(arg empty)', 'arg empty', ['empty'], ctx)),
- ('sim', ('$(arg baz)', 'arg baz', ['baz'], ctx)),
-
- # test with other args present, should only resolve match
- ('1234512345', ('$(arg foo)$(arg foo)', 'arg foo', ['foo'], ctx)),
- ('12345$(arg baz)', ('$(arg foo)$(arg baz)', 'arg foo', ['foo'], ctx)),
- ('$(arg foo)sim', ('$(arg foo)$(arg baz)', 'arg baz', ['baz'], ctx)),
-
- # test double-resolve safe
- ('12345', ('12345', 'arg foo', ['foo'], ctx)),
- ]
-
- for result, test in tests:
- resolved, a, args, context = test
- self.assertEquals(result, _arg(resolved, a, args, context))
-
- # - test that all fail if ctx is not set
- for result, test in tests:
- resolved, a, args, context = test
- try:
- _arg(resolved, a, args, {})
- self.fail("should have thrown")
- except ArgException, e:
- self.assertEquals(args[0], str(e))
- try:
- _arg(resolved, a, args, {'arg': {}})
- self.fail("should have thrown")
- except ArgException, e:
- self.assertEquals(args[0], str(e))
-
-
- def test_resolve_args(self):
- from roslib.substitution_args import resolve_args, SubstitutionException
- from roslib.packages import get_pkg_dir
- roslib_dir = get_pkg_dir('roslib', required=True)
-
- anon_context = {'foo': 'bar'}
- arg_context = {'fuga': 'hoge', 'car': 'cdr'}
- context = {'anon': anon_context, 'arg': arg_context }
-
- tests = [
- ('$(find roslib)', roslib_dir),
- ('hello$(find roslib)', 'hello'+roslib_dir),
- ('$(find roslib )', roslib_dir),
- ('$$(find roslib )', '$'+roslib_dir),
- ('$( find roslib )', roslib_dir),
- ('$(find roslib )', roslib_dir),
- ('$(find roslib)$(find roslib)', roslib_dir+roslib_dir),
- ('$(find roslib)/foo/bar.xml', roslib_dir+os.sep+'foo'+os.sep+'bar.xml'),
- (r'$(find roslib)\foo\bar.xml $(find roslib)\bar.xml', roslib_dir+os.sep+'foo'+os.sep+'bar.xml '+roslib_dir+os.sep+'bar.xml'),
- ('$(find roslib)\\foo\\bar.xml more/stuff\\here', roslib_dir+os.sep+'foo'+os.sep+'bar.xml more/stuff\\here'),
- ('$(env ROS_ROOT)', os.environ['ROS_ROOT']),
- ('$(env ROS_ROOT)', os.environ['ROS_ROOT']),
- ('$(env ROS_ROOT )', os.environ['ROS_ROOT']),
- ('$(optenv ROS_ROOT)', os.environ['ROS_ROOT']),
- ('$(optenv ROS_ROOT)$(optenv ROS_ROOT)', os.environ['ROS_ROOT']+os.environ['ROS_ROOT']),
- ('$(optenv ROS_ROOT alternate text)', os.environ['ROS_ROOT']),
- ('$(optenv NOT_ROS_ROOT)', ''),
- ('$(optenv NOT_ROS_ROOT)more stuff', 'more stuff'),
- ('$(optenv NOT_ROS_ROOT alternate)', 'alternate'),
- ('$(optenv NOT_ROS_ROOT alternate text)', 'alternate text'),
-
- # #1776
- ('$(anon foo)', 'bar'),
- ('$(anon foo)/baz', 'bar/baz'),
- ('$(anon foo)/baz/$(anon foo)', 'bar/baz/bar'),
-
- # arg
- ('$(arg fuga)', 'hoge'),
- ('$(arg fuga)$(arg fuga)', 'hogehoge'),
- ('$(arg car)$(arg fuga)', 'cdrhoge'),
- ('$(arg fuga)hoge', 'hogehoge'),
- ]
- for arg, val in tests:
- self.assertEquals(val, resolve_args(arg, context=context))
-
- # more #1776
- r = resolve_args('$(anon foo)/bar')
- self.assert_('/bar' in r)
- self.failIf('$(anon foo)' in r)
-
-
- # test against strings that should not match
- noop_tests = [
- '$(find roslib', '$find roslib', '', ' ', 'noop', 'find roslib', 'env ROS_ROOT', '$$', ')', '(', '()',
- None,
- ]
- for t in noop_tests:
- self.assertEquals(t, resolve_args(t))
- failures = [
- '$((find roslib))', '$(find $roslib)',
- '$(find)', '$(find roslib roslib)', '$(export roslib)',
- '$(env)', '$(env ROS_ROOT alternate)',
- '$(env NOT_SET)',
- '$(optenv)',
- '$(anon)',
- '$(anon foo bar)',
- ]
- for f in failures:
- try:
- resolve_args(f)
- self.fail("resolve_args(%s) should have failed"%f)
- except SubstitutionException: pass
-
-if __name__ == '__main__':
- rosunit.unitrun('test_roslib', 'test_substitution_args', SubArgsTest, coverage_packages=['roslib.substitution_args'])
-