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

add option to pass extra env to ament_add_*test #50

Merged
merged 3 commits into from
Dec 11, 2015

Conversation

wjwwood
Copy link
Contributor

@wjwwood wjwwood commented Dec 9, 2015

I needed this to pass some environment to tests on OS X. I think the changes are pretty self explanatory.

One nice thing is that you can pass generator expressions through this variable and it works, e.g. I have the cmake code:

ament_add_gtest(test_allocator
    test/rcl/test_allocator.cpp
    ENV DYLD_INSERT_LIBRARIES=$<TARGET_FILE:${PROJECT_NAME}_memory_tools_interpose>)

Which results in these args to run_test.py:

3: Test command: /usr/local/bin/python3 "-u" "/Users/william/ros2/install/share/ament_cmake_test/cmake/run_test.py" "/Users/william/ros2/build/rcl/test_results/rcl/test_time.gtest.xml" "--output-file" "/Users/william/ros2/build/rcl/ament_cmake_gtest/test_time.txt" "--env" "DYLD_INSERT_LIBRARIES=/Users/william/ros2/build/rcl/librcl_memory_tools_interpose.dylib" "--command" "/Users/william/ros2/build/rcl/test_time" "--gtest_output=xml:/Users/william/ros2/build/rcl/test_results/rcl/test_time.gtest.xml"
3: Test timeout computed to be: 60
3: -- run_test.py: extra environment variables:
3:  - DYLD_INSERT_LIBRARIES=/Users/william/ros2/build/rcl/librcl_memory_tools_interpose.dylib
3: -- run_test.py: invoking following command in '/Users/william/ros2/build/rcl':
3:  - /Users/william/ros2/build/rcl/test_time --gtest_output=xml:/Users/william/ros2/build/rcl/test_results/rcl/test_time.gtest.xml
3: Running main() from gtest_main.cc
[ ... ]

@wjwwood wjwwood added in progress Actively being worked on (Kanban column) in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Dec 9, 2015
@@ -47,7 +47,7 @@ macro(ament_add_gtest target)
endmacro()

function(_ament_add_gtest target)
cmake_parse_arguments(ARG "SKIP_LINKING_MAIN_LIBRARIES" "TIMEOUT" "" ${ARGN})
cmake_parse_arguments(ARG "SKIP_LINKING_MAIN_LIBRARIES" "TIMEOUT;ENV" "" ${ARGN})
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add ENV before TIMEOUT (for alpha. order) and document it in the docblock above.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should it be a multi-value argument instead to allow passing more then one?

@wjwwood
Copy link
Contributor Author

wjwwood commented Dec 11, 2015

Ok, I pushed an update and tested it locally with two environment variables. CI (for linux): http://ci.ros2.org/job/ci_linux/699/

@dirk-thomas
Copy link
Contributor

+1

wjwwood added a commit that referenced this pull request Dec 11, 2015
add option to pass extra env to ament_add_*test
@wjwwood wjwwood merged commit 747b668 into master Dec 11, 2015
@wjwwood wjwwood deleted the pass_extra_env_to_tests branch December 11, 2015 01:34
@wjwwood wjwwood removed the in review Waiting for review (Kanban column) label Dec 11, 2015
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

Successfully merging this pull request may close these issues.

2 participants