Skip to content

Commit

Permalink
Catch the new unsupported platform/accessory exceptions raised by the…
Browse files Browse the repository at this point in the history
… generator so the tests pass, use the envar when setting the default value of ROS_DISTRO
  • Loading branch information
civerachb-cpr committed Nov 6, 2024
1 parent 6fa195e commit 84e6e6e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
10 changes: 6 additions & 4 deletions clearpath_generator_common/clearpath_generator_common/ros.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

## The ROS distrbution this package has been bloomed for
ROS_DISTRO = 'jazzy'
import os

## Standard installation path for ROS distributions
ROS_DISTRO_PATH = f'/opt/ros/{ROS_DISTRO}/'
# The active ROS distribution
ROS_DISTRO = os.environ.get('ROS_DISTRO', 'jazzy')

# Standard installation path for ROS distributions
ROS_DISTRO_PATH = f'/opt/ros/{ROS_DISTRO}/'
8 changes: 8 additions & 0 deletions clearpath_generator_common/test/test_generator_bash.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
import shutil

from ament_index_python.packages import get_package_share_directory
from clearpath_config.common.types.exception import (
UnsupportedAccessoryException,
UnsupportedPlatformException,
)
from clearpath_generator_common.bash.generator import BashGenerator


Expand All @@ -49,6 +53,10 @@ def test_samples(self):
try:
rlg = BashGenerator(os.path.dirname(dst))
rlg.generate()
except UnsupportedAccessoryException as e:
print(f'Unsupported accessory: {e}')
except UnsupportedPlatformException as e:
print(f'Unsupported platform: {e}')
except Exception as e:
errors.append("Sample '%s' failed to load: '%s'" % (
sample,
Expand Down
10 changes: 10 additions & 0 deletions clearpath_generator_common/test/test_generator_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@

from ament_index_python.packages import get_package_share_directory

from clearpath_config.common.types.exception import (
UnsupportedAccessoryException,
UnsupportedPlatformException,
)
from clearpath_generator_common.description.generator import DescriptionGenerator

import xacro
Expand All @@ -52,6 +56,12 @@ def test_samples(self):
try:
rlg = DescriptionGenerator(os.path.dirname(dst))
rlg.generate()
except UnsupportedAccessoryException as e:
print(f'Unsupported accessory. {e}. Skipping')
continue
except UnsupportedPlatformException as e:
print(f'Unsupported platform. {e}. Skipping')
continue
except Exception as e:
errors.append("Sample '%s' failed to load: '%s'" % (
sample,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
import shutil

from ament_index_python.packages import get_package_share_directory
from clearpath_config.common.types.exception import (
UnsupportedAccessoryException,
UnsupportedPlatformException,
)
from clearpath_generator_common.discovery_server.generator import DiscoveryServerGenerator


Expand All @@ -49,6 +53,10 @@ def test_samples(self):
try:
rlg = DiscoveryServerGenerator(os.path.dirname(dst))
rlg.generate()
except UnsupportedAccessoryException as e:
print(f'Unsupported accessory. {e}')
except UnsupportedPlatformException as e:
print(f'Unsupported platform. {e}')
except Exception as e:
errors.append("Sample '%s' failed to load: '%s'" % (
sample,
Expand Down

0 comments on commit 84e6e6e

Please sign in to comment.