-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test to check if ros node is loadable
If we use python2 PYTHON_INTERPRETER on 20.04, python2 fails to load rospy in /opt/ros/noetic, because rospy moduels are alraedy updated. If we use python3 PYTHON_INTERPRETER on 18.04, python3 can load rospy in /opt/ros/melodic by chance. c.f. #367
- Loading branch information
Showing
3 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env python | ||
|
||
import rospy | ||
import os, sys, unittest, rostest | ||
|
||
class TestRospyNode(unittest.TestCase): | ||
|
||
def __init__(self, *args): | ||
unittest.TestCase.__init__(self, *args) | ||
|
||
def test_rosnode(self): | ||
__name__ = 'dummy' | ||
scripts_dir = os.path.abspath(os.path.join(os.path.realpath(__file__), os.pardir, os.pardir, 'node_scripts')) | ||
for filename in [f for f in map(lambda x: os.path.join(scripts_dir, x), os.listdir(scripts_dir)) if os.path.isfile(f)]: | ||
print("Check if {} is loadable".format(filename)) | ||
exec(open(filename).read()) in globals(), locals() | ||
self.assertTrue(True) | ||
|
||
if __name__ == '__main__': | ||
rostest.rosrun('test_rospy_node', 'ros_google_cloud_language', TestRospyNode, sys.argv) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<launch> | ||
<test pkg="ros_google_cloud_language" type="test_rospy_node.py" test-name="ros_rospy_node" /> | ||
</launch> |