Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

Conversation

nburek
Copy link
Contributor

@nburek nburek commented Aug 22, 2019

Adds if check around calling catkin_add_gmock in order to prevent the warning that is causing our builds to be "unstable".

Issue #, if available:
https://t.corp.amazon.com/P24962820

Description of changes:
Adds if check around calling catkin_add_gmock in order to prevent the warning that is causing our builds to be "unstable".

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Adds if check around calling catkin_add_gmock in order to prevent the warning that is causing our builds to be "unstable".
@nburek nburek requested a review from ryanewel August 22, 2019 23:32
@codecov
Copy link

codecov bot commented Aug 22, 2019

Codecov Report

Merging #43 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #43   +/-   ##
=======================================
  Coverage   81.33%   81.33%           
=======================================
  Files          11       11           
  Lines         375      375           
=======================================
  Hits          305      305           
  Misses         70       70
Flag Coverage Δ
#ROS_1 81.33% <ø> (ø) ⬆️
#ROS_2 81.23% <ø> (ø) ⬆️
#dashing 81.23% <ø> (ø) ⬆️
#kinetic 81.36% <ø> (ø) ⬆️
#melodic 81.23% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 855b91e...9d3c222. Read the comment docs.

Copy link
Contributor

@AAlon AAlon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this would break downstream packages when CATKIN_ENABLE_TESTING is turned off.

For example here we add the test and call target_.... With this change, when CATKIN_ENABLE_TESTING=0 the target wouldn't exist and the build would break.

One option is to audit all our CEs and add guards to check that targets exist like here (or create a macro for it in the utils package). A bit ugly and repetitive though... there might be more elegant solutions.

@mm318
Copy link
Contributor

mm318 commented Aug 23, 2019

I have a feeling we're not supposed to be calling enable_testing() directly.

@nburek
Copy link
Contributor Author

nburek commented Aug 26, 2019

Unfortunately this would break downstream packages when CATKIN_ENABLE_TESTING is turned off.

Good callout.

One option is to audit all our CEs and add guards to check that targets exist like here (or create a macro for it in the utils package). A bit ugly and repetitive though... there might be more elegant solutions.

I started to look at the option of creating a macro to see if testing is enabled that we could use in these ROS agnostic packages but ran into some issues. Because these builds aren't native Catkin/Ament, the CATKIN_ENABLE_TESTING and BUILD_TESTING variables are not being set by the build system, making it difficult to know if testing has been disabled or not. I'm trying to see if there is a work around for this.

@nburek
Copy link
Contributor Author

nburek commented Aug 26, 2019

I have a feeling we're not supposed to be calling enable_testing() directly.

We might not need to call enable_testing directly anymore if we're actually using Catkin/Ament to initialize the testing, but I'm not actually sure that we are. I also don't think it hurts to call this as long as we actually do want testing enabled for our package (https://cmake.org/cmake/help/v3.0/command/enable_testing.html).

@nburek
Copy link
Contributor Author

nburek commented Aug 26, 2019

Updated with a change that I think addresses @AAlon concern. I tested it by making the same change in the h264_encoder_core package that I made in aws_common package and it was able to build successfully when I set testing to be disabled.

However, in order actually disable testing I had to run the build as:
colcon build --catkin-cmake-args -DCATKIN_ENABLE_TESTING=0 --cmake-args -DCATKIN_ENABLE_TESTING=0
If I didn't include the --cmake-args ... it would just fall back to the default of CATKIN_ENABLE_TESTING=1, even though Catkin was given an argument to disable it. This leads me to believe that colcon will never give our CMake builds the same arguments that it gives to Catkin builds.

Even though this is kind of working right now, I would propose that we ditch using CATKIN_ENABLE_TESTING in favor of our own argument to make it clear that they are not the same and it should be provided as a cmake arg and not a catkin argument. Thoughts?

message(STATUS "Building tests using catkin")
set(GTEST_LIBRARIES "") # hack so that linking against libgmock doesn't also link against libgtest
catkin_add_gmock("${target}" ${ARGN})
if(CATKIN_ENABLE_TESTING)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So @AAlon was concerned about adding this because #39 loosened the condition to fix some build break.

Looking back at our previous discussions, I do believe we should be using CATKIN_ENABLE_TESTING somewhere. catkin_FOUND is too loose.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be using CATKIN_ENABLE_TESTING only when DefineTestMacros is being called from a package being built with catkin. Right now the way that we're trying to adhoc import catkin/ament seems kind of hacky. We may need to rehtink how we're building these packages

endif()

if(CATKIN_ENABLE_TESTING OR BUILD_TESTING)
set(aws_common_TESTING_ENABLED 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This DefineTestMacros.cmake file is used by many packages. It's not specific to aws_common.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I was trying to give the variable some sort of namespace to indicate where it comes from. Multiple packages use DefineTestMacros.cmake, but they all source it from aws_common. Open to other naming suggestions as well.

link_test_target(test_throttling_manager)
link_test_target(test_client_configuration_provider)
link_test_target(test_service_credentials_provider)
if (aws_common_TESTING_ENABLED)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good idea.

In the CMakeLists.txt of our ROS packages, they are guarded CATKIN_ENABLE_TESTING.

It makes sense for our ROS-less packages to be guarded by a similar variable (that's derived from catkin and ament testing variables).

In the same vein, our ROS2 packages should be made to do something similar as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants