From 838e51724054d659057edc1b6fa56d193279dbcd Mon Sep 17 00:00:00 2001 From: Thibault Kruse Date: Thu, 23 Feb 2012 21:31:18 +0000 Subject: [PATCH] Initial unittests for rosbash, to be expanded --- tools/rosbash/test/test_rosbash.bash | 31 ++++++++++++++++++++++++++++ tools/rosbash/test/test_scipts.py | 18 ++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100755 tools/rosbash/test/test_rosbash.bash create mode 100644 tools/rosbash/test/test_scipts.py diff --git a/tools/rosbash/test/test_rosbash.bash b/tools/rosbash/test/test_rosbash.bash new file mode 100755 index 00000000..a7dbe10e --- /dev/null +++ b/tools/rosbash/test/test_rosbash.bash @@ -0,0 +1,31 @@ +#! /usr/bin/env bash + +# This script is supposed to be a unit test for rosbash, also used for manual checks against other operating systems. + +# TODO extend this script + + +. ../rosbash + +export COMP_CWORD=1 +_roscomplete_launch roslaunch +if [[ ! ${COMPREPLY[@]} =~ rosbash ]]; then + echo "rosbash package missing from" ${COMPREPLY[@]} ; exit 1 +fi +echo success 1 + +export COMP_WORDS=("roslaunch" "--") +export COMP_CWORD=1 +_roscomplete_launch roslaunch "--" roslaunch +if [[ ! ${COMPREPLY[@]} == "--files --args --nodes --find-node --child --local --screen --server_uri --run_id --wait --port --core --pid --dump-params" ]]; then + echo "roslaunch --options missing" from ${COMPREPLY[@]} ; exit 1 +fi +echo success 2 + +export COMP_WORDS=("roslaunch" "roslaunch") +export COMP_CWORD=2 +_roscomplete_launch roslaunch roslaunch +if [[ ! ${COMPREPLY[@]} =~ "example.launch" ]]; then + echo "example.launch missing from " ${COMPREPLY[@]} ; exit 1 +fi +echo success 3 diff --git a/tools/rosbash/test/test_scipts.py b/tools/rosbash/test/test_scipts.py new file mode 100644 index 00000000..d054290f --- /dev/null +++ b/tools/rosbash/test/test_scipts.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +import os +import subprocess +import unittest + +PKG_PATH = os.getcwd() +TEST_PATH = os.path.join(PKG_PATH, 'test') + +class TestRosBash(unittest.TestCase): + + def setUp(self): + self.cmd = os.path.join(TEST_PATH, 'test_rosbash.bash') + self.assertTrue(os.path.exists(self.cmd)) + + def test_rosbash_completion(self): + subprocess.check_call([self.cmd], cwd = TEST_PATH) +