Skip to content

Commit

Permalink
Merge pull request #1261 from ubi-agni/fix-flaky-test
Browse files Browse the repository at this point in the history
Fix flaky test
  • Loading branch information
v4hn committed Dec 12, 2018
2 parents 1812bdb + 6e7bdc2 commit 1d78df5
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ SharedStorage& getSharedStorage()
#endif
}

// Deleter that, additionally to T*, deletes another object too
template <typename T, typename O>
struct CoupledDeleter
{
Expand All @@ -85,9 +86,9 @@ struct CoupledDeleter

void operator()(const T* p)
{
delete p;
if (other_)
delete other_;
delete p;
}
};
}
Expand Down
6 changes: 2 additions & 4 deletions moveit_ros/planning_interface/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ if (CATKIN_ENABLE_TESTING)
find_package(moveit_resources)
find_package(rostest)

add_rostest_gtest(test_cleanup cleanup.test cleanup.cpp)
add_executable(test_cleanup test_cleanup.cpp)
target_link_libraries(test_cleanup moveit_move_group_interface)

add_rostest(python_move_group.test)
add_rostest(python_move_group_ns.test)
add_rostest(robot_state_update.test)
add_rostest(cleanup.test)
endif()

install(PROGRAMS python_move_group.py python_move_group_ns.py DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/test)
install(FILES python_move_group.test python_move_group_ns.test DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/test)
13 changes: 9 additions & 4 deletions moveit_ros/planning_interface/test/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@ def __init__(self, *args, **kwargs):
super(CleanupTest, self).__init__(*args, **kwargs)
self._rospack = rospkg.RosPack()

def run_cmd(self, cmd, num = 5):
failures = 0
for i in range(num):
if subprocess.call(cmd) != 0:
failures += 1
self.assertEqual(failures, 0, "%d of %d runs failed" % (failures, num))

def test_py(self):
cmd = roslib.packages.find_node(PKGNAME, "movegroup_interface.py", self._rospack)
self.assertTrue(subprocess.call(cmd) == 0)
self.run_cmd(roslib.packages.find_node(PKGNAME, "test_cleanup.py", self._rospack))

def test_cpp(self):
cmd = roslib.packages.find_node(PKGNAME, "test_cleanup", self._rospack)
self.assertTrue(subprocess.call(cmd) == 0)
self.run_cmd(roslib.packages.find_node(PKGNAME, "test_cleanup", self._rospack))

if __name__ == '__main__':
rostest.rosrun(PKGNAME, NODENAME, CleanupTest)
3 changes: 0 additions & 3 deletions moveit_ros/planning_interface/test/python_move_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,3 @@ def test_validation(self):
NODENAME = 'moveit_test_python_move_group'
rospy.init_node(NODENAME)
rostest.rosrun(PKGNAME, NODENAME, PythonMoveGroupTest)

# suppress cleanup segfault
os._exit(0)
3 changes: 0 additions & 3 deletions moveit_ros/planning_interface/test/python_move_group_ns.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,3 @@ def test_validation(self):
NODENAME = 'moveit_test_python_move_group'
rospy.init_node(NODENAME)
rostest.rosrun(PKGNAME, NODENAME, PythonMoveGroupNsTest)

# suppress cleanup segfault
os._exit(0)

0 comments on commit 1d78df5

Please sign in to comment.