-
Notifications
You must be signed in to change notification settings - Fork 680
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
Fixed bug where including relative paths would fail to find the correct file #358
Conversation
This path lets tests access files relative to the executable for better transportability
I was able to make the tests pass regardless of which path the test executable is called in commit 9f9e4ab. It works by adding a gtest environment, which uses The new unit tests still aren't built for ROS1 or ROS2. @facontidavide should I add these tests to those environments or is it fine to leave them out? I think it's just a matter of copying the trees/ directory to the proper path, but I don't have any ROS installations to test this with. |
I am unavailable the next week, but I will try to review and merge this after that |
The file command only copies during the cmake configure step. If source files change, file is not ran again
@facontidavide it seems like a recent change in #373 has unintentionally broken tree inclusion. When including a file that has a tree with the
One thing of note is that this CI scenario doesn't seem to be included in the PR checks. |
I added this scenario in PR checks so the regression would be caught in the future. @facontidavide have you had a chance to review this PR and/or fix the regression? |
The environment trick is very neat. Thanks |
|
The broken build appears to be from a missing |
Atually:
This is happening on the Open Robotics CI server. Not sure how to set those variables |
It’s set by the root CMakeLists.txt BehaviorTree.CPP/CMakeLists.txt Line 255 in c14f25c
|
@facontidavide I believe this is failing because the Open Robotics CI server is building with ament, BehaviorTree.CPP/tests/CMakeLists.txt Lines 53 to 69 in 4fa2177
Since My recommendation is to remove |
I think the problem is not if the test is build or not. If it is built even if BUILD_TESTING is not set, no bug deal. The problem is really And the fact that CMAKE_BINARY_DIR is not set. Have a look at this, I think it is a better way to address the issue: #398 |
Removing the use of It's safe to rely on This entire block BehaviorTree.CPP/CMakeLists.txt Lines 250 to 257 in 4fa2177
isn't even executed in the Open Robotics CI build. That build would be calling this branch instead BehaviorTree.CPP/CMakeLists.txt Lines 234 to 245 in 4fa2177
since The bug in the Open Robotics CI build only crops up because this branch of test/CMakeLists.txt BehaviorTree.CPP/tests/CMakeLists.txt Lines 53 to 67 in 4fa2177
assumes that the pure CMake branch of the top-level CMakeLists.txt was executed which sets Another option is to restructure the branch in tests/CMakeLists.txt to look like this if(ament_cmake_FOUND)
if(BUILD_TESTING)
# ...
endif()
elseif(catkin_FOUND)
if(CATKIN_ENABLE_TESTING)
# ...
endif()
else()
if(BUILD_UNIT_TESTS)
# ...
endif()
endif() or restructure the if(BUILD_SAMPLES AND ((ament_cmake_FOUND AND BUILD_TESTING) OR (catkin_FOUND AND CATKIN_ENABLE_TESTING) OR (NOT ament_cmake_FOUND AND NOT catkin_FOUND AND BUILD_UNIT_TESTS)))
add_subdirectory(tests)
endif() |
By updating the
current_path
to the included file's absolute path before recursing, all relative paths are relative to the included file. After recursively including the new tree, the change tocurrent_path
is undone.Added unit tests to verify new behavior. The new unit tests aren't built for catkin or ament because I wasn't sure where to copy the test tree files.
Because the trees are included using relative paths to the test executable, they fail if the current working directory is not the same as the trees/ directory i.e.,
./behaviortree_cpp_v3_test
works but./bin/behaviortree_cpp_v3_test
fails. I'd like to resolve this prior to merging but not sure how to.Fixes #324