From aa7280c2f00002b11900760566df04ab4e3fe827 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Fri, 27 Oct 2023 13:42:57 +0900 Subject: [PATCH] dialogflow_task_executive: catkin_virtualenv : use SYSTEM_PACKAGES FALSE --- dialogflow_task_executive/CMakeLists.txt | 1 + dialogflow_task_executive/requirements.in.noetic | 1 + dialogflow_task_executive/test/test_rospy_node.py | 12 ++++++++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dialogflow_task_executive/CMakeLists.txt b/dialogflow_task_executive/CMakeLists.txt index 9e67eb43a..5b1b36999 100644 --- a/dialogflow_task_executive/CMakeLists.txt +++ b/dialogflow_task_executive/CMakeLists.txt @@ -60,6 +60,7 @@ elseif("$ENV{ROS_DISTRO}" STRGREATER "melodic") catkin_generate_virtualenv( INPUT_REQUIREMENTS requirements.in.noetic PYTHON_INTERPRETER python3 + USE_SYSTEM_PACKAGES FALSE ) else() catkin_generate_virtualenv( diff --git a/dialogflow_task_executive/requirements.in.noetic b/dialogflow_task_executive/requirements.in.noetic index 7fe2d496f..9a88c9342 100644 --- a/dialogflow_task_executive/requirements.in.noetic +++ b/dialogflow_task_executive/requirements.in.noetic @@ -3,3 +3,4 @@ google-api-core[grpc]==1.33.0 grpcio-status==1.48.1 googleapis-common-protos[grpc]==1.56.2 protobuf==3.20.1 # fix Could not find a version that matches protobuf<4.0.0dev,<5.0.0dev,>=3.15.0,>=3.20.1,>=4.21.3 (from google-api-core[grpc]==1.33.1->dialogflow==1.1.1->-r requirements.in (line 1)) +PyYAML==5.3.1 # USE_SYSTEM_PACKAGES FALSE needs yaml diff --git a/dialogflow_task_executive/test/test_rospy_node.py b/dialogflow_task_executive/test/test_rospy_node.py index 318d6c8d6..a56f75054 100644 --- a/dialogflow_task_executive/test/test_rospy_node.py +++ b/dialogflow_task_executive/test/test_rospy_node.py @@ -27,11 +27,15 @@ def test_rosnode(self): 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')]: + for filename in [f for f in map(lambda x: 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) + import subprocess + try: + ret = subprocess.check_output(['rosrun', pkg_name, filename], stderr=subprocess.STDOUT) + except subprocess.CalledProcessError as e: + print("Catch runtime error ({}), check if this is expect".format(e.output)) + self.assertTrue('Check the device is connected and recognized' in e.output) + if __name__ == '__main__': rostest.rosrun('test_rospy_node', pkg_name, TestRospyNode, sys.argv)