Skip to content

Commit

Permalink
rostest: use AnyMsg in publishtest (ros#1659)
Browse files Browse the repository at this point in the history
* publishtest: use AnyMsg in publishtest

* fix concerns
  • Loading branch information
beetleskin authored and tahsinkose committed Apr 15, 2019
1 parent 1b13d07 commit 9f3cc4f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions tools/rostest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if(CATKIN_ENABLE_TESTING)

add_rostest(test/hztest0.test)
add_rostest(test/hztest.test)
add_rostest(test/publishtest.test)
add_rostest(test/clean_master.test)
add_rostest(test/distro_version.test)
add_rostest(test/param.test)
Expand Down
4 changes: 1 addition & 3 deletions tools/rostest/nodes/publishtest
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,8 @@ class PublishChecker(object):
self.topic_name = topic_name
self.negative = negative
self.deadline = rospy.Time.now() + rospy.Duration(timeout)
msg_class, _, _ = rostopic.get_topic_class(
rospy.resolve_name(topic_name), blocking=True)
self.msg = None
self.sub = rospy.Subscriber(topic_name, msg_class, self._callback)
self.sub = rospy.Subscriber(topic_name, rospy.AnyMsg, self._callback)

def _callback(self, msg):
self.msg = msg
Expand Down
19 changes: 19 additions & 0 deletions tools/rostest/test/publishtest.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<launch>

<node pkg="rostopic" type="rostopic" name="freq_topic_pub" args="pub /frequent_topic std_msgs/Bool 'data: false' -r 10" />
<node pkg="rostopic" type="rostopic" name="once_topic_pub" args="pub /once_topic std_msgs/Bool 'data: false' -1l" />

<test test-name="publishtest_test" pkg="rostest" type="publishtest" time-limit="3.0" retry="3">
<rosparam>
topics:
- name: /frequent_topic
timeout: 2.
- name: /once_topic
timeout: 2.
- name: /unpublished_topic
timeout: 2.
negative: true
</rosparam>
</test>

</launch>

0 comments on commit 9f3cc4f

Please sign in to comment.