Skip to content

Feature requests: isolated testings (with ROS_DOMAIN_ID) #432

@huweiATgithub

Description

@huweiATgithub

Feature request

Feature description

The LaunchTestRunner or the LaunchROSTestItem should support running in an isolated environment like what ros2 test do: https://github.com/ros2/ros_testing/blob/a60a6d11b5761288f2238651ee4f48c3b99ad373/ros2test/ros2test/command/test.py#L39-L50
 

Implementation considerations

Suggested by the implementation in ros2test, we can write the runtest member function of the class LaunchROSTestItem as follows:

    def runtest(self):
        with contextlib.ExitStack() as stack:
            if "ROS_DOMAIN_ID" not in os.environ:
                domain_id = stack.enter_context(domain_coordinator.domain_id())
                os.environ["ROS_DOMAIN_ID"] = str(domain_id)
            if "ROS_DOMAIN_ID" in os.environ:
                print(f"ROS_DOMAIN_ID: {os.environ['ROS_DOMAIN_ID']}")
            return super().runtest()

To offer this feature as an option, we can supply arguments to the pytest mark

@pytest.mark.rostest(isolated=True)

I can submit a pull request implementing this feature if the proposal is approved.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp wantedExtra attention is needed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions