Skip to content

Instantly share code, notes, and snippets.

@Aposhian
Last active January 11, 2022 23:00
Show Gist options
  • Save Aposhian/cf1efc55311711649ad9c3b3e91f4c88 to your computer and use it in GitHub Desktop.
Save Aposhian/cf1efc55311711649ad9c3b3e91f4c88 to your computer and use it in GitHub Desktop.
Can't use event-triggered ReadyToTest
FROM ros:galactic
COPY setup.sh .
COPY launch.test.py .
RUN . /opt/ros/$ROS_DISTRO/setup.sh && python3 -m launch_testing.launch_test launch.test.py
import unittest
import pytest
from launch import LaunchDescription
from launch.actions import ExecuteProcess, RegisterEventHandler
from launch.event_handlers import OnProcessExit
from launch_testing.actions import ReadyToTest
@pytest.mark.launch_test
def generate_test_description():
setup = ExecuteProcess(cmd=["setup.sh"], output="screen")
return (
LaunchDescription(
[
setup,
RegisterEventHandler(
OnProcessExit(target_action=setup, on_exit=ReadyToTest())
),
]
),
{"setup": setup},
)
class TestTeachAndRepeat(unittest.TestCase):
def test_relying_on_setup(self, launch_service, proc_output):
print("Running the test!")
#!/usr/bin/env bash
echo "Doing complicated setup logic"
sleep 10
echo "I'm done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment