Skip to content

Commit 107e62b

Browse files
committed
test(console): add ros-interop feature gate and CI integration
Applied feature gating pattern from ros-z-tests to ros-z-console: - Added ros-interop feature flag to Cargo.toml - Added #![cfg(feature = "ros-interop")] to test file - Updated CI workflow to run ros-z-console tests with feature flag - Fixed type name assertions (std_msgs/msg/String not ::) Tests now properly gated behind ros-interop feature: - Without feature: 0 tests run (properly excluded) - With feature: 3 tests run and pass CI integration: - ros-z-console tests run alongside ros-z-tests in test.yml - Runs on both Humble and Jazzy distros - Uses cargo nextest with --features ros-interop
1 parent 87775bd commit 107e62b

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ jobs:
7171
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
7272
if [ "${{ matrix.distro }}" = "humble" ]; then
7373
cargo nextest run -p ros-z-tests --no-default-features --features ros-interop,humble --release
74+
cargo nextest run -p ros-z-console --features ros-interop --release
7475
else
7576
cargo nextest run -p ros-z-tests --features ros-interop,${{ matrix.distro }} --release
77+
cargo nextest run -p ros-z-console --features ros-interop --release
7678
fi

crates/ros-z-console/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,8 @@ chrono = { version = "0.4", features = ["serde"] }
2828
once_cell = { workspace = true }
2929
nix = { version = "0.29", features = ["signal"] }
3030
serial_test = "3.0"
31+
32+
[features]
33+
default = []
34+
# ROS interop tests require ros2 CLI with rmw_zenoh_cpp
35+
ros-interop = []

crates/ros-z-console/tests/dynamic_subscriber_test.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(feature = "ros-interop")]
2+
13
mod common;
24

35
use common::{ProcessGuard, TestRouter, check_ros2_available, spawn_ros2_topic_pub};
@@ -32,7 +34,6 @@ fn spawn_console_headless(router_endpoint: &str, echo_topics: &[&str]) -> Proces
3234
}
3335

3436
#[test]
35-
#[ignore = "requires ros2 CLI with rmw_zenoh_cpp"]
3637
fn test_dynamic_subscriber_std_msgs_string() {
3738
if !check_ros2_available() {
3839
println!("Skipping test: ros2 CLI not available");
@@ -81,7 +82,7 @@ fn test_dynamic_subscriber_std_msgs_string() {
8182
if let Ok(json) = serde_json::from_str::<Value>(&line) {
8283
if json["event"] == "topic_subscribed" {
8384
assert_eq!(json["topic"], "/chatter");
84-
assert_eq!(json["type_name"], "std_msgs::msg::String");
85+
assert_eq!(json["type_name"], "std_msgs/msg/String");
8586

8687
// Type hash should start with RIHS01_
8788
if let Some(hash) = json["type_hash"].as_str() {
@@ -109,7 +110,7 @@ fn test_dynamic_subscriber_std_msgs_string() {
109110

110111
if json["event"] == "message_received" {
111112
assert_eq!(json["topic"], "/chatter");
112-
assert_eq!(json["type"], "std_msgs::msg::String");
113+
assert_eq!(json["type"], "std_msgs/msg/String");
113114

114115
// Check that data field contains "hello from ros2"
115116
if let Some(data) = json["data"]["data"].as_str() {
@@ -128,7 +129,6 @@ fn test_dynamic_subscriber_std_msgs_string() {
128129
}
129130

130131
#[test]
131-
#[ignore = "requires ros2 CLI with rmw_zenoh_cpp"]
132132
fn test_dynamic_subscriber_sensor_msgs_laser_scan() {
133133
if !check_ros2_available() {
134134
println!("Skipping test: ros2 CLI not available");
@@ -186,7 +186,7 @@ fn test_dynamic_subscriber_sensor_msgs_laser_scan() {
186186
if let Ok(json) = serde_json::from_str::<Value>(&line) {
187187
if json["event"] == "topic_subscribed" {
188188
assert_eq!(json["topic"], "/scan");
189-
assert_eq!(json["type_name"], "sensor_msgs::msg::LaserScan");
189+
assert_eq!(json["type_name"], "sensor_msgs/msg/LaserScan");
190190

191191
if let Some(hash) = json["type_hash"].as_str() {
192192
assert!(hash.starts_with("RIHS01_"));
@@ -208,7 +208,7 @@ fn test_dynamic_subscriber_sensor_msgs_laser_scan() {
208208

209209
if json["event"] == "message_received" {
210210
assert_eq!(json["topic"], "/scan");
211-
assert_eq!(json["type"], "sensor_msgs::msg::LaserScan");
211+
assert_eq!(json["type"], "sensor_msgs/msg/LaserScan");
212212

213213
// Verify some fields from the data
214214
let data = &json["data"];
@@ -242,7 +242,6 @@ fn test_dynamic_subscriber_sensor_msgs_laser_scan() {
242242
}
243243

244244
#[test]
245-
#[ignore = "requires ros2 CLI with rmw_zenoh_cpp"]
246245
fn test_dynamic_subscriber_multiple_topics() {
247246
if !check_ros2_available() {
248247
println!("Skipping test: ros2 CLI not available");

0 commit comments

Comments
 (0)