Skip to content

Commit

Permalink
Address peer review comments.
Browse files Browse the repository at this point in the history
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
  • Loading branch information
hidmic committed Aug 7, 2019
1 parent 7963c1d commit d18ddea
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions launch/test/launch/test_launch_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

"""Tests for the LaunchService class."""

import asyncio
import osrf_pycommon
import queue
import threading

from launch import LaunchDescription
from launch import LaunchService
from launch.events import ExecutionComplete

import osrf_pycommon


def test_launch_service_constructors():
"""Test the constructors for LaunchService class."""
Expand Down Expand Up @@ -65,19 +65,25 @@ class MockEvent:
assert ls._LaunchService__context._event_queue.qsize() == 2
assert handled_events.qsize() == 0

# Spin up a background thread for testing purposes.
def perform_test_sequence():
# First event (after including description of event handler).
handled_events.get(block=True, timeout=5.0)
# Emit and then check for a second event.
ls.emit_event(MockEvent())
handled_events.get(block=True, timeout=5.0)
# Shutdown (generates a third event) and join the thread.
# Shutdown (generates a third event).
ls.shutdown()

threading.Thread(target=perform_test_sequence).start()
t = threading.Thread(target=perform_test_sequence)
t.start()

# Run the launch service.
assert ls.run(shutdown_when_idle=False) == 0

# Join background thread if still running.
t.join()

# Check that the shutdown event was handled.
handled_events.get(block=False)

Expand Down

0 comments on commit d18ddea

Please sign in to comment.