ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How do I make sure my python rostest depends on the package messages?

asked 2019-01-24 09:10:49 -0500

VictorLamoine gravatar image

I have a package that uses rostest with a python script to make sure that some ROS services are working correctly.

The tests runs and pass localy but not on a distant machine (GitLab CI):

Scanning dependencies of target clean_test_results_ros_robodk_post_processors
Removing test result files from '/builds/InstitutMaupertuis/ros_robodk_post_processors/catkin_workspace/build/test_results/ros_robodk_post_processors'
[100%] Built target clean_test_results_ros_robodk_post_processors
Scanning dependencies of target _run_tests_ros_robodk_post_processors_rostest_test_services.launch
Traceback (most recent call last):
  File "/builds/InstitutMaupertuis/ros_robodk_post_processors/catkin_workspace/src/ros_robodk_post_processors/scripts/services.py", line 6, in <module>
    from ros_robodk_post_processors.srv import *
ImportError: No module named ros_robodk_post_processors.srv
Traceback (most recent call last):
  File "/builds/InstitutMaupertuis/ros_robodk_post_processors/catkin_workspace/src/ros_robodk_post_processors/test/services_tests.py", line 5, in <module>
    from ros_robodk_post_processors.srv import *
ImportError: No module named ros_robodk_post_processors.srv
... logging to /root/.ros/log/rostest-runner-ed2dce3a-project-7702522-concurrent-0-1987.log
[ROSUNIT] Outputting test results to /builds/InstitutMaupertuis/ros_robodk_post_processors/catkin_workspace/build/test_results/ros_robodk_post_processors/rostest-test_services.xml
[Testcase: testservices_tests] ... FAILURE!
FAILURE: test [services_tests] did not generate test results
  File "/usr/lib/python2.7/unittest/case.py", line 329, in run
    testMethod()
  File "/opt/ros/melodic/lib/python2.7/dist-packages/rostest/runner.py", line 164, in fn
    self.assert_(os.path.isfile(test_file), "test [%s] did not generate test results"%test_name)
  File "/usr/lib/python2.7/unittest/case.py", line 422, in assertTrue
    raise self.failureException(msg)

It seems that the messages of the services can't be found even though I have specified that the messages are a dependency of the test target ( https://gitlab.com/InstitutMaupertuis... ):

cmake_minimum_required(VERSION 3.2)
project(ros_robodk_post_processors)
add_compile_options(-Wall -Wextra)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

## Find catkin macros and libraries
find_package(catkin REQUIRED COMPONENTS
  geometry_msgs
  message_generation
  message_runtime
  rospy
  rostest
  std_msgs
)

################################################
## Declare ROS messages, services and actions ##
################################################

# Common services to all post-processors
add_service_files(
  FILES
  MoveC.srv
  MoveJ.srv
  MoveL.srv
  Pause.srv
  ProgFinish.srv
  ProgSave.srv
  ProgSendRobot.srv
  ProgStart.srv
  RunCode.srv
  RunMessage.srv
  SetDO.srv
  SetFrame.srv
  SetSpeed.srv
  SetSpeedJoints.srv
  SetTool.srv
  SetZoneData.srv
  WaitDI.srv
)

# Motoman specifics
add_service_files(
  FILES
  Motoman/Arcof.srv
  Motoman/Arcon.srv
  Motoman/DontUseMFrame.srv
  Motoman/Macro.srv
  Motoman/SetFolder.srv
)

generate_messages(
  DEPENDENCIES
  geometry_msgs
  std_msgs
)

################################################
## Declare ROS dynamic reconfigure parameters ##
################################################

###################################
## catkin specific configuration ##
###################################

catkin_package(
  CATKIN_DEPENDS
  geometry_msgs
  message_runtime
  rospy
  rostest
  std_msgs
)

#############
## Install ##
#############

# RoboDK post processors git submodule
install(
  DIRECTORY
  scripts/robodk_postprocessors/
  DESTINATION
  ${CATKIN_PACKAGE_BIN_DESTINATION}/robodk_postprocessors/
)

# Services servers
install(
  PROGRAMS
  scripts/config.py
  scripts/motoman.py
  scripts/services.py
  DESTINATION
  ${CATKIN_PACKAGE_BIN_DESTINATION}
)

#############
## Testing ##
#############

if(CATKIN_ENABLE_TESTING)
  add_rostest(
    test/services.launch
    DEPENDENCIES
    ${PROJECT_NAME}_generate_messages_cpp
  )
endif()

Why is the test file failing to find the service messages ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-02-27 04:27:06 -0500

VictorLamoine gravatar image

updated 2019-02-27 04:27:22 -0500

The solution is to source the workspace before running the tests. I have never had to do this in a local machine so I am not sure what is the reason I have to do it in the continuous integration.

In short I have to do:

catkin_make tests
source devel/setup.bash
catkin_make run_tests
catkin_test_results
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-01-24 09:10:49 -0500

Seen: 629 times

Last updated: Feb 27 '19