From d6a3c9091186626285b2ac43279dcd73d005be8f Mon Sep 17 00:00:00 2001 From: Adam Heins Date: Tue, 27 Feb 2024 11:47:20 -0500 Subject: [PATCH] Add external packages for additional tests. --- .gitmodules | 6 ++++ README.md | 14 ++++----- pytest.ini | 2 ++ .../Universal_Robots_ROS2_Description | 1 + tests/packages/iit-walkman-ros-pkg | 1 + tests/test_extra_packages.py | 31 +++++++++++++++++++ tests/test_xacrodoc.py | 16 +++++----- 7 files changed, 56 insertions(+), 15 deletions(-) create mode 100644 .gitmodules create mode 100644 pytest.ini create mode 160000 tests/packages/Universal_Robots_ROS2_Description create mode 160000 tests/packages/iit-walkman-ros-pkg create mode 100644 tests/test_extra_packages.py diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..00ebcd7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "tests/packages/iit-walkman-ros-pkg"] + path = tests/packages/iit-walkman-ros-pkg + url = https://github.com/ADVRHumanoids/iit-walkman-ros-pkg.git +[submodule "tests/packages/Universal_Robots_ROS2_Description"] + path = tests/packages/Universal_Robots_ROS2_Description + url = https://github.com/UniversalRobots/Universal_Robots_ROS2_Description.git diff --git a/README.md b/README.md index 6b84182..166e89a 100644 --- a/README.md +++ b/README.md @@ -141,19 +141,19 @@ supported by other non-ROS tools. xacrodoc automatically expands these paths out to full absolute paths, but this can be disabled by passing `resolve_packages=False` to the `Xacrodoc` constructor. -## Development +## Testing -Tests use `pytest`. Ensure that the catkin workspace's setup file has been -sourced to make the package available, then do: +Tests use `pytest`. Some tests depend on additional submodules, which you can +clone using: +``` +git submodule update --init --recursive +``` +Then do: ``` cd tests pytest . ``` -For local testing, the project needs to be built as a ROS package in a catkin -workspace, which uses the `setup.py` file. For building and publishing to -PyPI, we use `poetry` and the configuration in `pyproject.toml`. - ## License [MIT](https://github.com/adamheins/xacrodoc/blob/main/LICENSE) diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..563ef7b --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +norecursedirs = tests/packages diff --git a/tests/packages/Universal_Robots_ROS2_Description b/tests/packages/Universal_Robots_ROS2_Description new file mode 160000 index 0000000..707b369 --- /dev/null +++ b/tests/packages/Universal_Robots_ROS2_Description @@ -0,0 +1 @@ +Subproject commit 707b36948d55be81a1d36f099cb4055ea9e27b67 diff --git a/tests/packages/iit-walkman-ros-pkg b/tests/packages/iit-walkman-ros-pkg new file mode 160000 index 0000000..d38fe56 --- /dev/null +++ b/tests/packages/iit-walkman-ros-pkg @@ -0,0 +1 @@ +Subproject commit d38fe56a844f80f699afac583faf17df5e1d5d97 diff --git a/tests/test_extra_packages.py b/tests/test_extra_packages.py new file mode 100644 index 0000000..34acc00 --- /dev/null +++ b/tests/test_extra_packages.py @@ -0,0 +1,31 @@ +"""Test compiling xacro files from third-party repositories.""" +from pathlib import Path + +import pytest + +from xacrodoc import XacroDoc + + +def test_walkman(): + # walkman is an old package and therefore contains a manifest.xml instead + # of package.xml + walkman_pkg_path = Path("packages/iit-walkman-ros-pkg/walkman_urdf") + if not walkman_pkg_path.exists(): + pytest.skip( + "Submodule iit-walkman-ros-pkg does not appear to be cloned." + ) + doc = XacroDoc.from_file(walkman_pkg_path / "urdf/walkman_robot.urdf.xacro") + + +def test_ur(): + # this is a recent packages that makes heavy use of substitutions and other + # modern xacro features + ur_urdf_path = Path("packages/Universal_Robots_ROS2_Description/urdf") + if not ur_urdf_path.exists(): + pytest.skip( + "Submodule Universal_Robots_ROS2_Description does not appear to be cloned." + ) + doc = XacroDoc.from_file( + ur_urdf_path / "ur.urdf.xacro", + subargs={"ur_type": "ur10", "name": "ur"}, + ) diff --git a/tests/test_xacrodoc.py b/tests/test_xacrodoc.py index f1929a1..33025aa 100644 --- a/tests/test_xacrodoc.py +++ b/tests/test_xacrodoc.py @@ -5,14 +5,14 @@ from xacrodoc import XacroDoc, packages -def setup_function(): - packages.walk_up_from(__file__) - - -def teardown_function(): - # packages is global state, so we reset it for each test - packages.reset() - +# def setup_function(): +# packages.walk_up_from(__file__) +# +# +# def teardown_function(): +# # packages is global state, so we reset it for each test +# packages.reset() +# def test_from_file(): doc = XacroDoc.from_file("files/threelink.urdf.xacro")