fkie/catkin_lint

Test dependencies for launch files

Closed this issue · 1 comments

Currently, using using <test> tags in launch files triggers a warning if the test node is not included as execution dependency in the package.xml. Instead, catkin_lint should check the test dependencies for <test> tags.

Steps to reproduce:

package.xml

<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
  <name>mypkg</name>
  <version>0.3.0</version>
  <description>...</description>
  <maintainer email="...">...</maintainer>
  <license>TODO</license>

  <buildtool_depend>catkin</buildtool_depend>

  <exec_depend>roslaunch</exec_depend>

  <test_depend condition="$ROS_PYTHON_VERSION == 2">python-catkin-lint</test_depend>
  <test_depend condition="$ROS_PYTHON_VERSION == 3">python3-catkin-lint</test_depend>
  <test_depend>roslaunch</test_depend>
  <test_depend>rostest</test_depend>
</package>

CMakeLists.txt

cmake_minimum_required(VERSION 3.0.2)
project(mypkg)

find_package(catkin REQUIRED)
catkin_package()

install(DIRECTORYlaunch
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

if (CATKIN_ENABLE_TESTING)
  find_package(roslint REQUIRED)
  roslint_custom(catkin_lint -W2 .)
  roslint_add_test()

  find_package(roslaunch REQUIRED)
  roslaunch_add_file_check(launch/some_launchfile.launch USE_TEST_DEPENDENCIES)

  find_package(rostest REQUIRED)
  add_rostest(launch/some_launchfile.launch)
endif()

some_launchfile.launch

<?xml version="1.0"?>
<launch>
  <param name="foo" value="bar"/>
  <test pkg="rostest" type="paramtest" name="test_agent_type" test-name="test_agent_type">
    <rosparam>
      param_name_target: "foo"
      param_value_expected: "bar"
    </rosparam>
  </test>
</launch>

Output:

mypkg: launch/some_launchfile.launch(19): warning: launch configuration needs exec_depend on 'rostest'
     * Your package refers to another package in one of its launch
     * files, but you do not have this dependency in your package.xml
     * You can ignore this problem with --ignore launch_depend

Thank you for the report! catkin_lint does not properly distinguish between application launch files and test launch files. I'll look into it.