Skip to content

Commit

Permalink
Fix the tests.
Browse files Browse the repository at this point in the history
Signed-off-by: ChenYing Kuo <evshary@gmail.com>
  • Loading branch information
evshary committed Dec 4, 2024
1 parent ce2fc08 commit 0e4bd45
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions zenoh-plugin-ros2dds/src/ros_discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,21 +582,23 @@ where

mod tests {
#[test]
#[ignore]
// Test ignored as it cannot be run at the same time than test_serde_after_iron()
// Both need different ROS_DISTRO env var, that cannot be changed between the 2 tests
// Run this test individually or with `cargo test -- --ignored``
fn test_serde_prior_to_iron() {
use std::str::FromStr;

use super::*;
use crate::ros2_utils::get_ros_distro;

let distro = get_ros_distro();
println!("ROS_DISTRO={}", distro);
if !ros_distro_is_less_than("iron") {
println!("The current ROS Distro is not prior to iron. Skip the test.");
return;
}

// ros_discovery_message sent by a component_container node on Humble started as such:
// - ros2 run rclcpp_components component_container --ros-args --remap __ns:=/TEST
// - ros2 component load /TEST/ComponentManager composition composition::Listener
// - ros2 component load /TEST/ComponentManager composition composition::Talker
std::env::set_var("ROS_DISTRO", "humble");
let ros_discovery_info_cdr: Vec<u8> = hex::decode(
"000100000110de17b1eaf995400c9ac8000001c1000000000000000003000000\
060000002f5445535400000011000000436f6d706f6e656e744d616e61676572\
Expand Down Expand Up @@ -636,7 +638,6 @@ mod tests {
)
.unwrap();

println!("ROS_DISTRO={}", get_ros_distro());
let part_info: ParticipantEntitiesInfo = cdr::deserialize(&ros_discovery_info_cdr).unwrap();
println!("{:?}", part_info);

Expand Down Expand Up @@ -675,11 +676,17 @@ mod tests {
use super::*;
use crate::ros2_utils::get_ros_distro;

let distro = get_ros_distro();
println!("ROS_DISTRO={}", distro);
if ros_distro_is_less_than("iron") {
println!("The current ROS Distro is prior to iron. Skip the test.");
return;
}

// ros_discovery_message sent by a component_container node on Iron started as such:
// - ros2 run rclcpp_components component_container --ros-args --remap __ns:=/TEST
// - ros2 component load /TEST/ComponentManager composition composition::Listener
// - ros2 component load /TEST/ComponentManager composition composition::Talker
std::env::set_var("ROS_DISTRO", "iron");
let ros_discovery_info_cdr: Vec<u8> = hex::decode(
"00010000010f20a26b2fbd8000000000000001c103000000060000002f544553\
5400000011000000436f6d706f6e656e744d616e616765720000000005000000\
Expand Down Expand Up @@ -711,7 +718,6 @@ mod tests {
)
.unwrap();

println!("ROS_DISTRO={}", get_ros_distro());
let part_info: ParticipantEntitiesInfo = cdr::deserialize(&ros_discovery_info_cdr).unwrap();
println!("{:?}", part_info);

Expand Down

0 comments on commit 0e4bd45

Please sign in to comment.