Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test to check if ros node is loadable, #463

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions dialogflow_task_executive/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ if(NOT (gcc_dump_machine MATCHES "x86_64-.*" OR gcc_dump_machine MATCHES "aarch6
third_party/boringssl-with-bazel/src/crypto/hrss/asm/poly_rq_mul.S:306: Error: bad register name `%rbp'
third_party/boringssl-with-bazel/src/crypto/hrss/asm/poly_rq_mul.S:308: Error: bad register expression
third_party/boringssl-with-bazel/src/crypto/hrss/asm/poly_rq_mul.S:309: Error: bad register name `%rsp'")
find_package(catkin)
catkin_package()
return()
endif()

find_package(catkin REQUIRED COMPONENTS
Expand Down Expand Up @@ -42,7 +39,11 @@ catkin_package(
CATKIN_DEPENDS message_runtime
)

if("$ENV{ROS_DISTRO}" STREQUAL "indigo")
if(NOT(gcc_dump_machine MATCHES "x86_64-.*" OR gcc_dump_machine MATCHES "aarch64-.*"))
message(WARNING "pip -i requirements.txt with grpcio works only with i686, so create dummy requirements.txt and run 'catkin_generate_virtualenv' for ${gcc_dump_machine}")
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/requirements.txt "")
catkin_generate_virtualenv(CHECK_VENV FALSE)
elseif("$ENV{ROS_DISTRO}" STREQUAL "indigo")
message(WARNING "following requirements.txt syntax is not support on 14.04")
message(WARNING "google-api-core[grpc]==1.31.5 # via google-cloud-language")
message(WARNING "so we intentionally use requirements.txt")
Expand All @@ -69,19 +70,24 @@ else()
)
endif()

file(GLOB NODE_SCRIPTS_FILES node_scripts/*.py)

file(GLOB PYTHON_SCRIPT_FILES node_scripts/*.py test/*.py)
catkin_install_python(
PROGRAMS ${NODE_SCRIPTS_FILES}
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
PROGRAMS ${PYTHON_SCRIPT_FILES}
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

install(DIRECTORY launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
USE_SOURCE_PERMISSIONS
)

if(CATKIN_ENABLE_TESTING)
find_package(catkin REQUIRED COMPONENTS roslaunch)
find_package(catkin REQUIRED COMPONENTS roslaunch rostest)
roslaunch_add_file_check(launch)
if(NOT (gcc_dump_machine MATCHES "x86_64-.*" OR gcc_dump_machine MATCHES "aarch64-.*"))
message(WARNING "pip -i requirements.txt work only with i686, so skipping test for ${gcc_dump_machine}")
else()
add_rostest(test/test_rospy_node.test
DEPENDENCIES ${PROJECT_NAME}_generate_virtualenv ${PROJECT_NAME}_generate_messages
)
endif()
endif()
2 changes: 2 additions & 0 deletions dialogflow_task_executive/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
<buildtool_depend>catkin</buildtool_depend>
<build_depend>catkin_virtualenv</build_depend>
<build_depend>message_generation</build_depend>
<build_depend>actionlib_msgs</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>roslaunch</build_depend>
<run_depend>app_manager</run_depend>
<run_depend>message_runtime</run_depend>
<run_depend>speech_recognition_msgs</run_depend>
<run_depend>topic_tools</run_depend>
<!-- <run_depend>python-dialogflow-pip</run_depend> install via catkin_virtualenv -->
<test_depend>rostest</test_depend>

<export>
<pip_requirements>requirements.txt</pip_requirements>
Expand Down
1 change: 1 addition & 0 deletions dialogflow_task_executive/requirements.txt.indigo
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ google-api-core==1.12.0
google-auth==1.6.3
google-auth-httplib2==0.0.3
googleapis-common-protos==1.6.0
grpcio==1.24.0
httplib2==0.14.0
idna==2.6
protobuf==3.12.2
Expand Down
37 changes: 37 additions & 0 deletions dialogflow_task_executive/test/test_rospy_node.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python

import rospy
import os, sys, unittest, rostest

# https://stackoverflow.com/questions/10971033/backporting-python-3-openencoding-utf-8-to-python-2
if sys.version_info[0] > 2:
# py3k
pass
else:
# py2
import __builtin__
def open(filename, encoding=None):
return __builtin__.open(filename)

pkg_dir = os.path.abspath(os.path.join(os.path.realpath(__file__), os.pardir, os.pardir))
pkg_name = os.path.basename(pkg_dir)

class TestRospyNode(unittest.TestCase):

def __init__(self, *args):
unittest.TestCase.__init__(self, *args)

def test_rosnode(self):
__name__ = 'dummy'
for scripts_dir in ['scripts', 'node_scripts']:
full_scripts_dir = os.path.join(pkg_dir, scripts_dir)
if not os.path.exists(full_scripts_dir):
continue
for filename in [f for f in map(lambda x: os.path.join(full_scripts_dir, x), os.listdir(full_scripts_dir)) if os.path.isfile(f) and f.endswith('.py')]:
print("Check if {} is loadable".format(filename))
# https://stackoverflow.com/questions/4484872/why-doesnt-exec-work-in-a-function-with-a-subfunction
exec(open(filename, encoding='utf-8').read()) in globals(), locals()
self.assertTrue(True)

if __name__ == '__main__':
rostest.rosrun('test_rospy_node', pkg_name, TestRospyNode, sys.argv)
3 changes: 3 additions & 0 deletions dialogflow_task_executive/test/test_rospy_node.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<launch>
<test pkg="dialogflow_task_executive" type="test_rospy_node.py" test-name="ros_rospy_node" />
</launch>
14 changes: 8 additions & 6 deletions google_chat_ros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,14 @@ catkin_generate_virtualenv(
# euslisp
file(GLOB EUSLISP_SCRIPTS scripts/*.l)
install(FILES ${EUSLISP_SCRIPTS}
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/scripts/)

# python
file(GLOB PYTHON_SCRIPTS scripts/*.py)
file(GLOB PYTHON_SCRIPT_FILES scripts/*.py test/*.py)
catkin_install_python(
PROGRAMS ${PYTHON_SCRIPTS}
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
PROGRAMS ${PYTHON_SCRIPT_FILES}
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

# python requirements
install(FILES requirements.txt
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
Expand All @@ -70,4 +69,7 @@ if(CATKIN_ENABLE_TESTING)
add_rostest(test/import.test
DEPENDENCIES ${PROJECT_NAME}_generate_virtualenv
)
add_rostest(test/test_rospy_node.test
DEPENDENCIES ${PROJECT_NAME}_generate_virtualenv
)
endif()
40 changes: 40 additions & 0 deletions google_chat_ros/test/test_rospy_node.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python

import rospy
import os, sys, unittest, rostest

# https://stackoverflow.com/questions/10971033/backporting-python-3-openencoding-utf-8-to-python-2
if sys.version_info[0] > 2:
# py3k
pass
else:
# py2
import __builtin__
def open(filename, encoding=None):
return __builtin__.open(filename)

pkg_dir = os.path.abspath(os.path.join(os.path.realpath(__file__), os.pardir, os.pardir))
pkg_name = os.path.basename(pkg_dir)

class TestRospyNode(unittest.TestCase):

def __init__(self, *args):
unittest.TestCase.__init__(self, *args)

def test_rosnode(self):
__name__ = 'dummy'
for scripts_dir in ['scripts', 'node_scripts']:
full_scripts_dir = os.path.join(pkg_dir, scripts_dir)
if not os.path.exists(full_scripts_dir):
continue
for filename in [f for f in map(lambda x: os.path.join(full_scripts_dir, x), os.listdir(full_scripts_dir)) if os.path.isfile(f) and f.endswith('.py')]:
if filename.endswith('/helper.py'):
print("{} depends on dialogflow_task_executive. However, when we add this to the <depend> of package.xml, it appempts to build venv using 'dialogflow_task_executive/requirements.txt'. This requires having the same PYTHON_INTERPRETER for both dialogflow and chat ros package. The issue is that dialogflow_task_executive heavily relies on system Python modules, including ROS, making it difficult to use dialogflow with Python3 on Melodic".format(filename))
continue
print("Check if {} is loadable".format(filename))
# https://stackoverflow.com/questions/4484872/why-doesnt-exec-work-in-a-function-with-a-subfunction
exec(open(filename, encoding='utf-8').read()) in globals(), locals()
self.assertTrue(True)

if __name__ == '__main__':
rostest.rosrun('test_rospy_node', pkg_name, TestRospyNode, sys.argv)
3 changes: 3 additions & 0 deletions google_chat_ros/test/test_rospy_node.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<launch>
<test pkg="google_chat_ros" type="test_rospy_node.py" test-name="ros_rospy_node" />
</launch>
2 changes: 1 addition & 1 deletion julius_ros/test/julius.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<node name="rosbag_play" pkg="rosbag" type="play"
args="--delay 10 $(find julius_ros)/test/wave.bag" />

<test test-name="test_julius" pkg="julius_ros" type="test_julius.py" >
<test test-name="test_julius" pkg="julius_ros" type="test_julius.py" time-limit="60" >
<rosparam subst_value="true">
dnn: $(arg dnn)
</rosparam>
Expand Down
15 changes: 11 additions & 4 deletions nfc_ros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ catkin_generate_virtualenv(
PYTHON_INTERPRETER python3
CHECK_VENV FALSE
)
catkin_install_python(PROGRAMS
node_scripts/nfc_ros_node.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
file(GLOB PYTHON_SCRIPT_FILES node_scripts/*.py test/*.py)
catkin_install_python(
PROGRAMS ${PYTHON_SCRIPT_FILES}
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

install(FILES requirements.txt
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

if(CATKIN_ENABLE_TESTING)
find_package(rostest REQUIRED)
add_rostest(test/test_rospy_node.test
DEPENDENCIES ${PROJECT_NAME}_generate_virtualenv
)
endif()
endif()
37 changes: 37 additions & 0 deletions nfc_ros/test/test_rospy_node.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python

import rospy
import os, sys, unittest, rostest

# https://stackoverflow.com/questions/10971033/backporting-python-3-openencoding-utf-8-to-python-2
if sys.version_info[0] > 2:
# py3k
pass
else:
# py2
import __builtin__
def open(filename, encoding=None):
return __builtin__.open(filename)

pkg_dir = os.path.abspath(os.path.join(os.path.realpath(__file__), os.pardir, os.pardir))
pkg_name = os.path.basename(pkg_dir)

class TestRospyNode(unittest.TestCase):

def __init__(self, *args):
unittest.TestCase.__init__(self, *args)

def test_rosnode(self):
__name__ = 'dummy'
for scripts_dir in ['scripts', 'node_scripts']:
full_scripts_dir = os.path.join(pkg_dir, scripts_dir)
if not os.path.exists(full_scripts_dir):
continue
for filename in [f for f in map(lambda x: os.path.join(full_scripts_dir, x), os.listdir(full_scripts_dir)) if os.path.isfile(f) and f.endswith('.py')]:
print("Check if {} is loadable".format(filename))
# https://stackoverflow.com/questions/4484872/why-doesnt-exec-work-in-a-function-with-a-subfunction
exec(open(filename, encoding='utf-8').read()) in globals(), locals()
self.assertTrue(True)

if __name__ == '__main__':
rostest.rosrun('test_rospy_node', pkg_name, TestRospyNode, sys.argv)
3 changes: 3 additions & 0 deletions nfc_ros/test/test_rospy_node.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<launch>
<test pkg="nfc_ros" type="test_rospy_node.py" test-name="ros_rospy_node" />
</launch>
13 changes: 10 additions & 3 deletions respeaker_ros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ find_package(catkin REQUIRED COMPONENTS
dynamic_reconfigure
)

catkin_python_setup()

generate_dynamic_reconfigure_options(
cfg/Respeaker.cfg
)
Expand All @@ -15,10 +17,12 @@ catkin_package()
if($ENV{ROS_DISTRO} STRGREATER "melodic")
catkin_generate_virtualenv(
PYTHON_INTERPRETER python3
CHECK_VENV FALSE
)
else()
catkin_generate_virtualenv(
PYTHON_INTERPRETER python2
CHECK_VENV FALSE
)
endif()

Expand All @@ -29,13 +33,16 @@ install(FILES requirements.txt
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

file(GLOB PYTHON_SCRIPTS scripts/*.py)
catkin_install_python(PROGRAMS ${PYTHON_SCRIPTS}
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/scripts/)
file(GLOB PYTHON_SCRIPT_FILES scripts/*.py test/*.py)
catkin_install_python(PROGRAMS ${PYTHON_SCRIPT_FILES}
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

if(CATKIN_ENABLE_TESTING)
find_package(rostest REQUIRED)
add_rostest(test/sample_respeaker.test
DEPENDENCIES ${PROJECT_NAME}_generate_virtualenv
)
add_rostest(test/test_rospy_node.test
DEPENDENCIES ${PROJECT_NAME}_generate_virtualenv
)
endif()
2 changes: 0 additions & 2 deletions respeaker_ros/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
<exec_depend>tf</exec_depend>
<exec_depend condition="$ROS_PYTHON_VERSION == 2">python-numpy</exec_depend>
<exec_depend condition="$ROS_PYTHON_VERSION == 3">python3-numpy</exec_depend>
<exec_depend>python-pixel-ring-pip</exec_depend>
<exec_depend condition="$ROS_PYTHON_VERSION == 2">python-pyaudio</exec_depend>
<exec_depend condition="$ROS_PYTHON_VERSION == 3">python3-pyaudio</exec_depend>
<exec_depend>python-pyusb-pip</exec_depend>

<test_depend>jsk_tools</test_depend>

Expand Down
4 changes: 4 additions & 0 deletions respeaker_ros/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
SpeechRecognition==3.8.1
# see https://github.com/jsk-ros-pkg/jsk_robot/pull/1797
pyusb==1.1.1
spidev==3.5 # pixel-ring requires spidev and spidev >=3.6 requires setuptools>=61.0. same as https://github.com/jsk-ros-pkg/jsk_robot/pull/1794
pixel-ring==0.1.0
2 changes: 1 addition & 1 deletion respeaker_ros/scripts/respeaker_gencfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import os
import sys
from respeaker_node import PARAMETERS, RespeakerInterface
from respeaker_ros import PARAMETERS, RespeakerInterface


def main(out):
Expand Down
Loading