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 runner option to ament_add_test #174

Merged
merged 3 commits into from
Jun 6, 2019

Conversation

pbaughman
Copy link
Contributor

@pbaughman pbaughman commented Jun 4, 2019

Allow the user of ament_add_gtest and ament_add_pytest_test to specify a different test runner. This will be used by ROS2 tests so they can optionally specify a runner that provides isolation between tests running in parallel

(resolves #172)

A note about changing dependencies:

Previously, the dependencies for ament_cmake_test looked like this:

$ colcon list --topological-graph --packages-up-to ament_cmake_test
ament_package     +*.                                                                                          
ament_cmake_core   +*                                                                                          
ament_cmake_test    +                                                                                          

In this PR, I changed run_test.py from a python script to a python script that imports most of its functionality from a new python library called ament_add_test. This required me to change the dependencies of ament_cmake_test to depend on ament_cmake_python. Now the deps look like this:

$ colcon list --topological-graph --packages-up-to ament_cmake_test
ament_package       +*..                                                                                          
ament_cmake_core     +**                                                                                          
ament_cmake_python    +*                                                                                          
ament_cmake_test       +                                                                                          

As you can see, this did not cause many other indirect dependencies. Since ament_cmake_test relied on python anyway (to execute run_test.py) I think this is OK.

@pbaughman
Copy link
Contributor Author

@tfoote This is the first of two PRs required to implement isolated testing for ROS2. This change is ROS agnostic, but will allow us to have wrappers around ament_add_pytest_test and ament_add_gtest that set up the test isolation

@wjwwood This is the approach we discussed last week that keeps ROS stuff out of ament. I will create a follow-up PR in ament_cmake_ros with the aforementioned wrappers.

@wjwwood wjwwood requested a review from dirk-thomas June 4, 2019 23:24
@wjwwood
Copy link
Contributor

wjwwood commented Jun 4, 2019

@dirk-thomas can you comment on the change in the dependency structure due to this change? Is it ok or is there a better way to do this to avoid that dependency?

Copy link
Contributor

@dirk-thomas dirk-thomas left a comment

Choose a reason for hiding this comment

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

can you comment on the change in the dependency structure due to this change?

The added dependency looks reasonable to me.

ament_cmake_gtest/cmake/ament_add_gtest.cmake Show resolved Hide resolved
@@ -83,6 +83,7 @@ function(ament_add_gtest_test target)
COMMAND ${cmd}
OUTPUT_FILE "${CMAKE_BINARY_DIR}/ament_cmake_gtest/${target}.txt"
RESULT_FILE "${result_file}"
RUNNER "${ARG_RUNNER}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this not be added conditionally only - same as in ament_add_gtest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll make it match the style of the other arguments. Note that ament_add_gtest does things differently than ament_add_gtest_test and ament_add_pytest_test even before my change

ament_cmake_pytest/cmake/ament_add_pytest_test.cmake Outdated Show resolved Hide resolved
ament_cmake_test/ament_cmake_test/__init__.py Show resolved Hide resolved
ament_cmake_test/cmake/ament_add_test.cmake Show resolved Hide resolved
@dirk-thomas dirk-thomas added enhancement New feature or request in progress Actively being worked on (Kanban column) requires-changes labels Jun 5, 2019
@pbaughman pbaughman force-pushed the add_runner_option branch 2 times, most recently from f0dc669 to 5115416 Compare June 5, 2019 17:04
@pbaughman
Copy link
Contributor Author

@dirk-thomas Ok, I think the history is fixed now. Git blame on github, and on my machine now shows you and William wrote most of the code of ament_cmake_test/__init__.py 4 years ago.

@pbaughman
Copy link
Contributor Author

pbaughman commented Jun 5, 2019

@dirk-thomas Ok, I think this is ready to go. I believe I've addressed all of your comments and I tested it along with ros2/ament_cmake_ros#3 and verified that rcl and rclpy can use the new 'isolated' version of the test functions successfully

@pbaughman
Copy link
Contributor Author

@dirk-thomas 👍

@dirk-thomas
Copy link
Contributor

Since we don't want to squash on merge can you please squash the commit 4 (and soon 5) into the first commit. Thanks.

Pete Baughman added 3 commits June 6, 2019 09:35
  - By default, still uses run_test.py
  - Example use case: ament_cmake_ros can use a test runner that sets a ROS_DOMAIN_ID

Signed-off-by: Pete Baughman <pete.baughman@apex.ai>
  - This should let us see the history

Signed-off-by: Pete Baughman <pete.baughman@apex.ai>
  - Adds an ament_cmake_test python package

Signed-off-by: Pete Baughman <pete.baughman@apex.ai>
@pbaughman
Copy link
Contributor Author

@dirk-thomas Done

@dirk-thomas
Copy link
Contributor

Sanity check to rule out regressions: Build Status

@dirk-thomas
Copy link
Contributor

Thanks for the enhancement.

@dirk-thomas dirk-thomas merged commit 5918ede into ament:master Jun 6, 2019
@dirk-thomas dirk-thomas removed the in progress Actively being worked on (Kanban column) label Jun 6, 2019
@pbaughman pbaughman deleted the add_runner_option branch June 6, 2019 18:08
nuclearsandwich pushed a commit that referenced this pull request Mar 20, 2020
* ament_cmake allow speficiation of a different test runner

  - By default, still uses run_test.py
  - Example use case: ament_cmake_ros can use a test runner that
    sets a ROS_DOMAIN_ID

Signed-off-by: Pete Baughman <pete.baughman@apex.ai>

* ament_cmake move run_test.py to a python module

  - This should let us see the history

Signed-off-by: Pete Baughman <pete.baughman@apex.ai>

* ament_cmake refactor run_test.py into an importable python module

  - Adds an ament_cmake_test python package

Signed-off-by: Pete Baughman <pete.baughman@apex.ai>
nuclearsandwich pushed a commit that referenced this pull request Mar 23, 2020
* ament_cmake allow speficiation of a different test runner

  - By default, still uses run_test.py
  - Example use case: ament_cmake_ros can use a test runner that
    sets a ROS_DOMAIN_ID

Signed-off-by: Pete Baughman <pete.baughman@apex.ai>

* ament_cmake move run_test.py to a python module

  - This should let us see the history

Signed-off-by: Pete Baughman <pete.baughman@apex.ai>

* ament_cmake refactor run_test.py into an importable python module

  - Adds an ament_cmake_test python package

Signed-off-by: Pete Baughman <pete.baughman@apex.ai>
Signed-off-by: Steven! Ragnarök <steven@nuclearsandwich.com>
nuclearsandwich added a commit that referenced this pull request Apr 11, 2020
* Add runner option to ament_add_test (#174)

* ament_cmake allow speficiation of a different test runner

  - By default, still uses run_test.py
  - Example use case: ament_cmake_ros can use a test runner that
    sets a ROS_DOMAIN_ID

Signed-off-by: Pete Baughman <pete.baughman@apex.ai>

* ament_cmake move run_test.py to a python module

  - This should let us see the history

Signed-off-by: Pete Baughman <pete.baughman@apex.ai>

* ament_cmake refactor run_test.py into an importable python module

  - Adds an ament_cmake_test python package

Signed-off-by: Pete Baughman <pete.baughman@apex.ai>
Signed-off-by: Steven! Ragnarök <steven@nuclearsandwich.com>

* improve handling of encoding (#181)

Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
Signed-off-by: Steven! Ragnarök <steven@nuclearsandwich.com>

* use deterministic order for updated env vars (#196)

Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
Signed-off-by: Steven! Ragnarök <steven@nuclearsandwich.com>

* Run tests in current binary directory, not global source directory (#206)

Switch to CMAKE_CURRENT_BINARY_DIR for consistency with CTest

Signed-off-by: Dan Rose <dan@digilabs.io>
Signed-off-by: Steven! Ragnarök <steven@nuclearsandwich.com>

* remove status attribute from result XML, add skipped tag instead (#218)

Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
Signed-off-by: Steven! Ragnarök <steven@nuclearsandwich.com>

* Declare AMENT_TEST_RESULTS_DIR as a PATH (#221)

Signed-off-by: Dan Rose <dan@digilabs.io>
Signed-off-by: Steven! Ragnarök <steven@nuclearsandwich.com>

* Generate xunit files valid for the junit10.xsd

Signed-off-by: Jose Luis Rivero <jrivero@osrfoundation.org>
Signed-off-by: Steven! Ragnarök <steven@nuclearsandwich.com>

* Revert "Run tests in current binary directory, not global source directory (#206)"

This reverts commit 4354d62.

Signed-off-by: Steven! Ragnarök <steven@nuclearsandwich.com>

Co-authored-by: Peter Baughman <dblue135@yahoo.com>
Co-authored-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
Co-authored-by: Dan Rose <rotu@users.noreply.github.com>
Co-authored-by: Jose Luis Rivero <jrivero@osrfoundation.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

I would like to extend run_test.py to provide ROS_DOMAIN_ID isolation
3 participants