Skip to content

Commit

Permalink
Remove setting package file_type as a boolean in ROS discovery plugin. (
Browse files Browse the repository at this point in the history
  • Loading branch information
tdenewiler authored Jul 26, 2022
1 parent 60a1fae commit b8431ad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
9 changes: 3 additions & 6 deletions statick_tool/plugins/discovery/ros_discovery_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ def scan(
and ros_version is not None
):
logging.info(" Package is ROS%s.", ros_version)
package["ros"] = True
if ros_version == "1":
package["catkin"] = True
package["is_ros1"] = True
elif ros_version == "2":
distro = os.getenv("ROS_DISTRO")
path = os.getenv("PATH")
Expand All @@ -62,6 +61,7 @@ def scan(
package[
"cmake_flags"
] = "-DCMAKE_PREFIX_PATH=" + item.rstrip("/bin")
package["is_ros2"] = True
elif os.path.isfile(package_file) and ros_version is not None:
with open(package_file, encoding="utf8") as fconfig:
try:
Expand All @@ -71,11 +71,8 @@ def scan(
xmltodict.ParsingInterrupted,
) as exc:
# No valid XML found, so we are not going to find the build type.
package["ros"] = False
logging.warning(" Invalid XML in %s: %s", package_file, exc)
return
if self.deep_get(output, "package.export.build_type") == "ament_python":
logging.info(" Package is ROS%s.", ros_version)
package["ros"] = True
else:
package["ros"] = False
package["is_ros2"] = True
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def test_ros_discovery_plugin_scan_valid():
)
os.environ["ROS_VERSION"] = "1"
rdp.scan(package, "level")
assert package["ros"]
assert "is_ros1" in package
assert "is_ros2" not in package


def test_ros_discovery_plugin_scan_ros2_python_only():
Expand All @@ -86,7 +87,8 @@ def test_ros_discovery_plugin_scan_ros2_python_only():
)
os.environ["ROS_VERSION"] = "2"
rdp.scan(package, "level")
assert package["ros"]
assert "is_ros2" in package
assert "is_ros1" not in package


def test_ros_discovery_plugin_scan_invalid_no_ros_distro():
Expand All @@ -98,7 +100,8 @@ def test_ros_discovery_plugin_scan_invalid_no_ros_distro():
)
del os.environ["ROS_VERSION"]
rdp.scan(package, "level")
assert not package["ros"]
assert "is_ros1" not in package
assert "is_ros2" not in package


def test_ros_discovery_plugin_scan_invalid_badpath():
Expand All @@ -109,7 +112,8 @@ def test_ros_discovery_plugin_scan_invalid_badpath():
)
os.environ["ROS_VERSION"] = "1"
rdp.scan(package, "level")
assert not package["ros"]
assert "is_ros1" not in package
assert "is_ros2" not in package


def test_ros_discovery_plugin_scan_invalid_nocmake():
Expand All @@ -122,7 +126,8 @@ def test_ros_discovery_plugin_scan_invalid_nocmake():
)
os.environ["ROS_VERSION"] = "1"
rdp.scan(package, "level")
assert not package["ros"]
assert "is_ros1" not in package
assert "is_ros2" not in package


def test_ros_discovery_plugin_scan_invalid_packagexml():
Expand All @@ -135,7 +140,8 @@ def test_ros_discovery_plugin_scan_invalid_packagexml():
)
os.environ["ROS_VERSION"] = "1"
rdp.scan(package, "level")
assert not package["ros"]
assert "is_ros1" not in package
assert "is_ros2" not in package


def test_ros_discovery_plugin_ros2_scan_valid():
Expand All @@ -152,7 +158,8 @@ def test_ros_discovery_plugin_ros2_scan_valid():
os.environ["ROS_VERSION"] = "2"
os.environ["ROS_DISTRO"] = "foxy"
rdp.scan(package, "level")
assert package["ros"]
assert "is_ros2" in package
assert "is_ros1" not in package


def test_ros_discovery_plugin_ros1_scan_valid():
Expand All @@ -164,5 +171,5 @@ def test_ros_discovery_plugin_ros1_scan_valid():
)
os.environ["ROS_VERSION"] = "1"
rdp.scan(package, "level")
assert package["ros"]
assert package["catkin"]
assert "is_ros1" in package
assert "is_ros2" not in package

0 comments on commit b8431ad

Please sign in to comment.