Beispiel #1
0
def test_description():
    target_action = launch.actions.ExecuteProcess(cmd='dummy')
    included_action = launch.Action()
    not_included_action = launch.Action()

    dut = StdoutReadyListener(target_action=target_action,
                              ready_txt='test text',
                              actions=[included_action])

    description = dut.describe()
    assert description[1] == [included_action]
    assert not_included_action not in description[1]  # Sanity check
Beispiel #2
0
    def test_wait_for_wrong_message(self):
        data = []

        self.launch_description.add_entity(
            launch.actions.RegisterEventHandler(
                StdoutReadyListener(
                    target_action=self.terminating_proc,
                    ready_txt='not_ready',
                    actions=[
                        launch.actions.OpaqueFunction(
                            function=lambda context: data.append('ok'))
                    ])))

        launch_service = launch.LaunchService()
        launch_service.include_launch_description(self.launch_description)
        launch_service.run()

        # We should not get confused by output that doesn't match the ready_txt
        self.assertNotIn('ok', data)
Beispiel #3
0
    def test_wait_for_ready(self):
        data = []

        self.launch_description.add_entity(
            launch.actions.RegisterEventHandler(
                StdoutReadyListener(
                    target_action=self.terminating_proc,
                    ready_txt='Ready',
                    actions=[
                        launch.actions.OpaqueFunction(
                            function=lambda context: data.append('ok'))
                    ])))

        launch_service = launch.LaunchService()
        launch_service.include_launch_description(self.launch_description)
        launch_service.run()

        # If the StdoutReadyListener worked, we should see 'ok' in the data
        self.assertIn('ok', data)
Beispiel #4
0
    def test_wait_for_wrong_process(self):
        data = []

        self.launch_description.add_entity(
            launch.actions.RegisterEventHandler(
                StdoutReadyListener(
                    target_action=KeepAliveProc(
                    ),  # We never launched this process
                    ready_txt='Ready',
                    actions=[
                        launch.actions.OpaqueFunction(
                            function=lambda context: data.append('ok'))
                    ])))

        launch_service = launch.LaunchService()
        launch_service.include_launch_description(self.launch_description)
        launch_service.run()

        # We should not get confused by output from another proc
        self.assertNotIn('ok', data)