unary stacks support for rosstack and roslib
This commit is contained in:
parent
5e3ffe47d4
commit
05e0ce6061
|
@ -98,6 +98,13 @@ class RoslibPackagesTest(unittest.TestCase):
|
|||
self.assertEquals(foo_p, cache['foo'][0])
|
||||
self.assertEquals(bar_p, cache['bar'][0])
|
||||
|
||||
def test_list_pkgs_unary(self):
|
||||
d = roslib.packages.get_pkg_dir('test_roslib')
|
||||
d = os.path.join(d, 'test', 'stack_tests_unary')
|
||||
cache = {}
|
||||
packages = roslib.packages.list_pkgs(pkg_dirs=[d], cache=cache)
|
||||
self.assertEquals(set(['foo', 'bar']), set(packages))
|
||||
|
||||
def test_find_node(self):
|
||||
import roslib.packages
|
||||
d = roslib.packages.get_pkg_dir('test_roslib')
|
||||
|
|
|
@ -113,6 +113,32 @@ class RoslibStacksTest(unittest.TestCase):
|
|||
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 = os.environ.get(roslib.rosenv.ROS_PACKAGE_PATH, None)
|
||||
try:
|
||||
paths = [d]
|
||||
os.environ[roslib.rosenv.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[roslib.rosenv.ROS_PACKAGE_PATH] = rpp
|
||||
else:
|
||||
del os.environ[roslib.rosenv.ROS_PACKAGE_PATH]
|
||||
|
||||
def test_get_stack_dir(self):
|
||||
import roslib.rosenv
|
||||
import roslib.packages
|
||||
|
|
|
@ -1152,9 +1152,7 @@ void ROSStack::crawl_for_stacks(bool force_crawl)
|
|||
continue;
|
||||
if (ent->d_name[0] == '.')
|
||||
continue; // ignore hidden dirs
|
||||
else if (Stack::is_package(child_path))
|
||||
continue; // ignore this guy, he's a leaf.
|
||||
if (Stack::is_stack(child_path))
|
||||
else if (Stack::is_stack(child_path))
|
||||
{
|
||||
add_stack(child_path);
|
||||
/*
|
||||
|
@ -1179,6 +1177,8 @@ void ROSStack::crawl_for_stacks(bool force_crawl)
|
|||
Stack::stacks.push_back(newp);
|
||||
*/
|
||||
}
|
||||
else if (Stack::is_package(child_path))
|
||||
continue; // ignore this guy, he's a leaf.
|
||||
//check to make sure we're allowed to descend
|
||||
else if (!Stack::is_no_subdirs(child_path))
|
||||
q.push_front(CrawlQueueEntry(child_path));
|
||||
|
|
Loading…
Reference in New Issue