Skip to content

Commit e1efd85

Browse files
committed
Add test that structure is as expected
1 parent 04ff165 commit e1efd85

File tree

5 files changed

+776
-2
lines changed

5 files changed

+776
-2
lines changed

rclrs/src/dynamic_message.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,11 @@ impl DynamicMessageMetadata {
257257
let pkg = DynamicMessagePackage::new(package_name)?;
258258
pkg.message_metadata(type_name)
259259
}
260+
261+
/// Returns a description of the message structure.
262+
pub fn structure(&self) -> &MessageStructure {
263+
&self.structure
264+
}
260265
}
261266

262267
#[cfg(test)]

rclrs_tests/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ edition = "2021"
88
path = "src/lib.rs"
99

1010
[dependencies]
11-
anyhow = {version = "1", features = ["backtrace"]}
12-
test_msgs = {version = "*"}
11+
test_msgs = "*"
1312

1413
[dependencies.rclrs]
1514
version = "*"
15+
features = ["dyn_msg"]
1616

1717
[dependencies.rosidl_runtime_rs]
1818
version = "*"

rclrs_tests/build.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use std::env;
2+
3+
const ROS_DISTRO: &str = "ROS_DISTRO";
4+
5+
fn get_env_var_or_abort(env_var: &'static str) -> String {
6+
if let Ok(value) = env::var(env_var) {
7+
value
8+
} else {
9+
panic!(
10+
"{} environment variable not set - please source ROS 2 installation first.",
11+
env_var
12+
);
13+
}
14+
}
15+
16+
fn main() {
17+
let ros_distro = get_env_var_or_abort(ROS_DISTRO);
18+
println!("cargo:rustc-cfg=ros_distro=\"{ros_distro}\"");
19+
}

0 commit comments

Comments
 (0)