Skip to content

Commit

Permalink
Merge pull request #178 from ros2/fix_flaky_pendulum_test
Browse files Browse the repository at this point in the history
use ros2run api to handle KeyboardInterrupt
  • Loading branch information
dirk-thomas authored Sep 26, 2017
2 parents c6dd83c + 9fd8a4c commit 4444f34
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions pendulum_control/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<test_depend>launch</test_depend>
<test_depend>launch_testing</test_depend>
<test_depend>rmw_implementation_cmake</test_depend>
<test_depend>ros2run</test_depend>

<export>
<build_type>ament_cmake</build_type>
Expand Down
6 changes: 4 additions & 2 deletions pendulum_control/test/execute_with_delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
# limitations under the License.

import argparse
import subprocess
import sys
import time

from ros2run.api import run_executable


def main():
parser = argparse.ArgumentParser(description='Delay and execute an executable.')
Expand All @@ -27,7 +28,8 @@ def main():

delay_time = args.delay * 0.001
time.sleep(delay_time)
return subprocess.call(args.executable)
# use ros2run api to handle KeyboardInterrupt
return run_executable(path=args.executable[0], argv=args.executable[1:])


if __name__ == '__main__':
Expand Down

0 comments on commit 4444f34

Please sign in to comment.