Skip to content

Commit f2ca13e

Browse files
committed
Ensure that test_graph_empty works even if the system has ROS_DOMAIN_ID set to 99
Signed-off-by: Michael X. Grey <[email protected]>
1 parent 1b6eeb4 commit f2ca13e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

rclrs/src/node/graph.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,24 @@ mod tests {
459459

460460
#[test]
461461
fn test_graph_empty() {
462+
let domain_id: usize = std::env::var("ROS_DOMAIN_ID")
463+
.ok()
464+
.and_then(|value| value.parse().ok())
465+
.map(|value| {
466+
if value == 99 {
467+
// The default domain ID for this application is 99, which
468+
// conflicts with our arbitrarily chosen default for the
469+
// empty graph test. Therefore we will set the empty graph
470+
// test domain ID to 98 instead.
471+
98
472+
} else {
473+
99
474+
}
475+
})
476+
.unwrap_or(99);
477+
462478
let context =
463-
Context::new_with_options([], InitOptions::new().with_domain_id(Some(99))).unwrap();
479+
Context::new_with_options([], InitOptions::new().with_domain_id(Some(domain_id))).unwrap();
464480
let node_name = "test_publisher_names_and_types";
465481
let node = Node::new(&context, node_name).unwrap();
466482
// Test that the graph has no publishers

0 commit comments

Comments
 (0)