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

make rostest build dependency in CMakeLists.txt optional #3010

Closed
dirk-thomas opened this issue Feb 4, 2014 · 12 comments
Closed

make rostest build dependency in CMakeLists.txt optional #3010

dirk-thomas opened this issue Feb 4, 2014 · 12 comments

Comments

@dirk-thomas
Copy link
Member

(Originally filled by @bulwahn at ros/catkin#588)

We want to make the rostest build dependency in the CMakeLists.txt of all ROS packages optional.

This shall been done by the refactoring the CMakeLists.txt from:

find_package(catkin REQUIRED COMPONENTS [...] roscpp rostest)
[...]
if(CATKIN_ENABLE_TESTING)
  add_subdirectory(test)
endif()

to:

find_package(catkin REQUIRED COMPONENTS [...] roscpp)   [! drop rostest !]
[...]
if(CATKIN_ENABLE_TESTING)
  find_package(rostest)  [! add this line in the CATKIN_ENABLE_TESTING conditional block !]
  add_subdirectory(test)
endif()

For commits addressing this task, their commit message shall refer to this issue by
make rostest in CMakeLists optional (ros/rosdistro#3010).

This has been discussed on the ros-sig-buildsystem [1], and prepares for the roll-out of the REP 140 [2].

[1] https://groups.google.com/forum/#!topic/ros-sig-buildsystem/Ub7ktrLPSe0
[2] https://github.com/jack-oquin/rep/blob/master/rep-0140.rst

@dirk-thomas
Copy link
Member Author

Just a comment stated earlier: this requires REP 140 to be active, implemented and rolled out. Otherwise you can not get rid of the build dependency in the package.xml file. The time frame for this is still not yet clear based on the slow progress in the last year.

@bulwahn
Copy link

bulwahn commented Feb 4, 2014

To clarify the task in this issue, this is limited to the changes in the CMakeLists.txt file.
The package.xml will not be modified. Hence, this means that the CMakeLists.txt does not require the rostest package if CATKIN_ENABLE_TESTING is not set to 1, but the overall build system still will require it.

bulwahn added a commit to bulwahn/actionlib that referenced this issue Feb 27, 2014
bulwahn added a commit to bulwahn/filters that referenced this issue Feb 27, 2014
bulwahn added a commit to bulwahn/geometry that referenced this issue Feb 27, 2014
bulwahn added a commit to bulwahn/geometry that referenced this issue Feb 27, 2014
bulwahn added a commit to bulwahn/image_common that referenced this issue Feb 27, 2014
esteve added a commit to ros/actionlib that referenced this issue Feb 27, 2014
vrabaud added a commit to ros-perception/image_common that referenced this issue Feb 27, 2014
bulwahn added a commit to bulwahn/navigation that referenced this issue Feb 27, 2014
bulwahn added a commit to bulwahn/ros_tutorials that referenced this issue Feb 27, 2014
bulwahn added a commit to bulwahn/ros_comm that referenced this issue Feb 27, 2014
dirk-thomas pushed a commit to ros/ros_comm that referenced this issue Feb 27, 2014
tfoote added a commit to ros/filters that referenced this issue Feb 27, 2014
make rostest in CMakeLists optional (ros/rosdistro#3010)
tfoote added a commit to ros/geometry that referenced this issue Feb 27, 2014
@bulwahn
Copy link

bulwahn commented Mar 18, 2014

As rostest is still a build dependency for now, this change is only a first step that remains ineffective for most use cases, but mainly prepares for the roll-out of REP 140. However, the installation routines for OpenEmbedded [1] rely only on the CMakeLists, and not on the information in the package.xml. So, it can exploit this refined setup before REP 140 is in place, and explore the possible problematic cases for REP 140's roll-out.

bulwahn added a commit to bmwcarit/ros_chatter that referenced this issue Mar 19, 2014
bulwahn added a commit to bulwahn/camera_info_manager_py that referenced this issue Apr 8, 2014
jack-oquin added a commit to ros-perception/camera_info_manager_py that referenced this issue Apr 8, 2014
make rostest in CMakeLists optional (ros/rosdistro#3010)
dirk-thomas pushed a commit to ros/ros_tutorials that referenced this issue May 1, 2014
@dirk-thomas
Copy link
Member Author

We just applied the change to geometry and found and issue with the proposed approach. When find_package(rostest) is invoked that will reset the catkin variables (catkin_INLCUDE_DIRS, catkin_LIBRARIES, etc.).

While that does not affect Python testing it will lead to missing symbols when trying to link test executables without the collect libraries of found catkin packages.

We likely have to change the behavior of catkin to support this use case (only set the variables when being invoked with find_package(catkin COMPONENTS ...). But since that change significant it might not be backported to older distro. That would imply that any package using this new approach and using C++ tests should only apply the change on its Indigo branch.

@jack-oquin
Copy link
Member

I've been wondering about this problem. In packages I maintain, it generally works OK because there is seldom anything left to build at the end of the CMakeLists.txt where tests are defined.

When there are test programs to compile under CATKIN_ENABLE_TESTING, what is the recommended approach? Should we do something like this?

if (CATKIN_ENABLE_TESTING)
  add_executable(${PROJECT_NAME}_trigger_node tests/trigger_node.cpp)
  target_link_libraries(${PROJECT_NAME}_trigger_node
                        ${catkin_LIBRARIES}
                        ${DC1394_LIBRARY})
  find_package(catkin REQUIRED COMPONENTS rostest)
  add_rostest(tests/no_device_node.test)
  add_rostest(tests/no_device_nodelet.test)
endif()

@wjwwood
Copy link
Member

wjwwood commented May 3, 2014

But since that change significant it might be backported to older distro.

@dirk-thomas did you mean "might not be backported"?

@dirk-thomas
Copy link
Member Author

@jack-oquin Finding rostest through catkin is neither necessary nor recommended.

Currently the order to first build all test target (while the catkin variables are intact) and then find rostest before registering the tests is the only way which works. But since the order should not be completely different then outside of the testing block the referenced change in catkin aims to allow finding rostest early without affecting the catkin variables.

@wjwwood At the time of writing I thought the patch might not be backported. But after some further discussion it might be viable to backport it.

@jack-oquin
Copy link
Member

Finding rostest through catkin is neither necessary nor recommended.

OK.

What is necessary and recommended?

@dirk-thomas
Copy link
Member Author

It is necessary to find_package(rostest) since the package wants to use its CMake functions/macros.

It is not necessary to find_package(catkin) since the package does not want the catkin_* variables and especially does not want them to be overwritten.

The recommended way is what is posted in the first comment of this ticket. If the package has C++ unit tests which requires additional packages as dependencies the user may either:

find these dependencies individually and use their variables (just showing the libraries in the example):

find_package(dep1)
find_package(dep2)
...
target_link_libraries(my_test_target ${catkin_LIBRARIES} ${dep1_LIBRARIES} ${dep2_LIBRARIES})

or use catkin but take care of saving the variable content before:

set(saved_LIBRARIES ${catkin_LIBRARIES})
find_package(catkin REQUIRED COMPONENTS dep1 dep2)
...
target_link_libraries(my_test_target ${saved_LIBRARIES} ${catkin_LIBRARIES})

@jack-oquin
Copy link
Member

So, the recommended version of my example would be:

if (CATKIN_ENABLE_TESTING)
  add_executable(${PROJECT_NAME}_trigger_node tests/trigger_node.cpp)
  target_link_libraries(${PROJECT_NAME}_trigger_node
                        ${catkin_LIBRARIES}
                        ${DC1394_LIBRARY})
  find_package(rostest REQUIRED)
  add_rostest(tests/no_device_node.test)
  add_rostest(tests/no_device_nodelet.test)
endif()

The only change being `find_package()``?

@dirk-thomas
Copy link
Member Author

LGTM.

For the more difficult case where your test executable needs to compile/link against additional packages which need to be find_package()-ed in the test block we will need a different more complex template. I am not sure which of my previous options is less weird / more intuitive though.

mikeferguson added a commit to ros-planning/navigation that referenced this issue May 20, 2014
adolfo-rt pushed a commit to ros-controls/ros_control that referenced this issue Jul 30, 2014
make rostest in CMakeLists optional (ros/rosdistro#3010)
adolfo-rt pushed a commit to ros-controls/ros_control that referenced this issue Jul 30, 2014
make rostest in CMakeLists optional (ros/rosdistro#3010)
bulwahn added a commit to bulwahn/diagnostics that referenced this issue Jul 31, 2014
severin-lemaignan pushed a commit to severin-lemaignan/robotpkg that referenced this issue Aug 18, 2014
Changes since 1.9.30:

^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package tf
^^^^^^^^^^^^^^^^^^^^^^^^

1.11.3 (2014-05-07)
-------------------
* convert to boost signals2 following `ros/ros_comm#267
<https://github.com/ros/ros_comm/issues/267>`_ Fixes `#23
<https://github.com/ros/geometry/issues/23>`_. Requires
`ros/geometry2#61
<https://github.com/ros/geometry_experimental/issues/61>`_ as well.
* add rospy publisher queue_size argument
  `ros/ros_comm#169 <https://github.com/ros/ros_comm/issues/169>`_
* add queue_size to tf publisher
  `ros/ros_comm#169 <https://github.com/ros/ros_comm/issues/169>`_
* make rostest in CMakeLists optional (`ros/rosdistro#3010
<https://github.com/ros/rosdistro/issues/3010>`_)
* Contributors: Lukas Bulwahn, Tully Foote

1.11.2 (2014-02-25)
-------------------
* fixing test linking
* Contributors: Tully Foote

1.11.1 (2014-02-23)
-------------------

1.11.0 (2014-02-14)
-------------------
* TF uses ros::MessageEvent to get connection information
* Contributors: Kevin Watts, Tully Foote

1.10.8 (2014-02-01)
-------------------
* Port groovy-devel patch to hydro-devel
* Added rosconsole as catkin dependency for catkin_package
* Add rosconsole as runtime dependency
* Contributors: Michael Ferguson, Mirza Shah

1.10.7 (2013-12-27)
-------------------
* fix bug in tf::Matrix3x3::getEulerYPR()
  Fixes a bug in tf::Matrix3x3::getEulerYPR() implementation's handling
  of gimbal lock cases (when the new x axis aligns with the old +/-z
  axis).
* add test that demonstrated bug in tf::Matrix3x3
  tf::Matrix3x3::getEulerYPR() has a bug which returns an incorrect rpy
  for certain corner case inputs.  This test demonstrates that bug.
* Fix const correctness of tf::Vector3 rotate() method
  The method does not modify the class thus should be const.
  This has already been fixed in Bullet itself.
* add automatic tf buffer cleaning on bag loop for python
  This logic was already implemented for c++
  but not for the python module.
* Contributors: Acorn Pooley, Timo Rohling, Tully Foote, v4hn

1.10.6 (2013-08-28)
-------------------
* switching to wrapper scripts which will provide a deprecation warning for `#3
<https://github.com/ros/geometry/issues/3>`_
* add missing roswtf dependency to really export the plugin (fix `#27
<https://github.com/ros/geometry/issues/27>`_)
* Update listener.py
  Fix the tf listener service exception in rospy. See:
  http://answers.ros.org/question/10777/service-exception-using-tf-listener-in-rospy/
* Fix MessageFilter race condition
  If MessageFilter does not explicitly stop its callback timer when it's
  being destroyed, there is a race condition when that timer is processed in
  a callback queue run by a different thread.  Specifically,
  maxRateTimerCallback() may be called after messages_mutex_ has been
  destroyed, causing a unrecoverable error.

1.10.5 (2013-07-19)
-------------------
* tf: export dependency on tf2_ros
  Fixes `#21 <https://github.com/ros/geometry/issues/21>`_
* added run dependency on graphviz
  closes `#19 <https://github.com/ros/geometry/issues/19>`_

1.10.4 (2013-07-11)
-------------------
* fixing erase syntax
* resolving ros/geometry#18 using implementation
added in tf2::BufferCore, adding dependency on next version of tf2 for this

1.10.3 (2013-07-09)
-------------------
* fixing unittest for new resolve syntax

1.10.2 (2013-07-09)
-------------------
* strip leading slashes in resolve, and also any time a method is passed from
tf to tf2 assert the leading slash is stripped as well.  tf::resolve with two
arguments will end up with foo/bar instead of /foo/bar.  Fixes
ros/geometry2#12
* added two whitespaces to make message_filter compile with c++11
  more on this here:
  http://stackoverflow.com/questions/10329942/error-unable-to-find-string-literal-operator-slashes
* using CATKIN_ENABLE_TESTING to optionally configure tests in tf

1.10.1 (2013-07-05)
-------------------
* updating dependency requirement to tf2_ros 0.4.3
* removing unused functions
  removing unused private methods
  removing ``max_extrapolation_distance_``
  removing unused data storage _frameIDs frameIDS_reverse ``frame_authority_``
  removing cache_time from tf, passing through method to tf2 buffer_core
  removing unused variables ``frames_`` and ``frame_mutex_`` and
  ``interpolating_``
  removing unused mutex and transformchanged signaling
  commenting on deprecation of MAX_EXTRAPOLATION_DISTANCE

1.10.0 (2013-07-05)
-------------------
* adding versioned dependency on recent geometry_experimental changes
* fixing test dependencies
* fixing callbacks for message filters
* remove extra invalid comment
* dedicated thread logic all implemented
* removing commented out code
* mostly completed conversion of tf::TransformListener to use tf2 under the
hood
* lookuptwist working
* tf::Transformer converted to use tf2::Buffer under the hood.  passing
tf_unittest.cpp
* making tf exceptions typedefs of tf2 exceptions for compatability
* first stage of converting Transformer to Buffer
* switching to use tf2's TransformBroadcaster
* adding dependency on tf2_ros to start moving over contents
* fixing unit tests
severin-lemaignan pushed a commit to severin-lemaignan/robotpkg that referenced this issue Aug 18, 2014
Changes since 1.10.5:

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package camera_info_manager
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1.11.3 (2014-05-19)
-------------------
* Add public member function to manually set camera info (`#19
  <https://github.com/ros-perception/image_common/issues/19>`_)
* make rostest in CMakeLists optional (`ros/rosdistro#3010
  <https://github.com/ros/rosdistro/issues/3010>`_)
* Contributors: Jack O'Quin, Jonathan Bohren, Lukas Bulwahn
vrabaud added a commit to ros-perception/laser_assembler that referenced this issue Jan 18, 2015
make rostest in CMakeLists optional (ros/rosdistro#3010)
@dirk-thomas
Copy link
Member Author

I will close this since we there are no action items left based on the discussion. It is possible to workaround it within the CMake file of a package as illustrated by the example. Please feel free to comment with more information if you think this still needs some work.

bulwahn added a commit to bulwahn/slam_gmapping that referenced this issue Apr 5, 2017
bulwahn added a commit to bulwahn/cv_camera that referenced this issue Apr 5, 2017
OTL pushed a commit to OTL/cv_camera that referenced this issue Apr 5, 2017
bulwahn added a commit to bulwahn/rosauth that referenced this issue Apr 5, 2017
bulwahn added a commit to bulwahn/executive_smach that referenced this issue Apr 5, 2017
bulwahn added a commit to bulwahn/navigation that referenced this issue Apr 5, 2017
bulwahn added a commit to bulwahn/diagnostics that referenced this issue Apr 5, 2017
bulwahn added a commit to bulwahn/robot_state_publisher that referenced this issue Apr 15, 2017
This commit has the same intentions as commit f3f1c4d on the
indigo branch.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
mikeferguson added a commit to ros-planning/navigation that referenced this issue Apr 16, 2017
mikeferguson pushed a commit to ros-planning/navigation that referenced this issue Apr 16, 2017
mikeferguson pushed a commit to ros-planning/navigation that referenced this issue Apr 16, 2017
trainman419 added a commit to ros/diagnostics that referenced this issue Apr 25, 2017
130s added a commit to ros/executive_smach that referenced this issue Jun 2, 2017
make rostest in CMakeLists optional (ros/rosdistro#3010)
130s pushed a commit to 130s/executive_smach that referenced this issue Jun 3, 2017
130s pushed a commit to 130s/executive_smach that referenced this issue Jun 8, 2017
vrabaud added a commit to ros-perception/slam_gmapping that referenced this issue Aug 6, 2017
sloretz pushed a commit to ros/robot_state_publisher that referenced this issue Oct 27, 2017
* make rostest in CMakeLists optional (ros/rosdistro#3010)
* rostest is now a test_depend instead of a build_depend
johaq pushed a commit to CentralLabFacilities/navigation that referenced this issue Mar 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants