Skip to content

Commit 214470a

Browse files
authored
Fixes for releasing to crates.io (#231)
* Fixups for releasing to crates.io * Removed std_msgs as test dependency. Fix rosidl_runtime_rs version * Removed test * Removed test
1 parent 25eabf7 commit 214470a

File tree

8 files changed

+6
-179
lines changed

8 files changed

+6
-179
lines changed

rclrs/Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ version = "0.2.0"
44
# This project is not military-sponsored, Jacob's employment contract just requires him to use this email address
55
authors = ["Esteve Fernandez <[email protected]>", "Nikolai Morin <[email protected]>", "Jacob Hassold <[email protected]>"]
66
edition = "2021"
7+
license = "Apache-2.0"
8+
description = "A ROS 2 client library for developing robotics applications in Rust"
79

810
[lib]
911
path = "src/lib.rs"
@@ -16,17 +18,14 @@ libc = "0.2.43"
1618
# Provides better concurrency primitives than std
1719
parking_lot = "0.11.2"
1820
# Needed for the Message trait, among others
19-
rosidl_runtime_rs = "*"
21+
rosidl_runtime_rs = "0.2.0"
2022
# Needed for clients
2123
futures = "0.3"
2224

2325
[dev-dependencies]
2426
# Needed for e.g. writing yaml files in tests
2527
tempfile = "3.3.0"
2628

27-
[dev-dependencies.std_msgs]
28-
version = "*"
29-
3029
[build-dependencies]
3130
# Needed for FFI
3231
bindgen = "0.59.1"

rclrs/package.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
<build_depend>rosidl_runtime_rs</build_depend>
1818
<build_depend>rcl</build_depend>
1919

20-
<test_depend>std_msgs</test_depend>
21-
2220
<export>
2321
<build_type>ament_cargo</build_type>
2422
</export>

rclrs/src/lib.rs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -147,44 +147,3 @@ pub fn create_node(context: &Context, node_name: &str) -> Result<Node, RclrsErro
147147
pub fn create_node_builder(context: &Context, node_name: &str) -> NodeBuilder {
148148
Node::builder(context, node_name)
149149
}
150-
151-
#[cfg(test)]
152-
mod tests {
153-
use super::*;
154-
use std::sync::{Arc, Mutex};
155-
use std::time::Duration;
156-
157-
#[test]
158-
fn test_spin_once() -> Result<(), RclrsError> {
159-
let context = Context::new(vec![]).unwrap();
160-
let mut subscriber_node = create_node(&context, "minimal_subscriber")?;
161-
let num_messages = Arc::new(Mutex::new(0));
162-
let received_msg = Arc::new(Mutex::new(String::new()));
163-
let n = num_messages.clone();
164-
let m = received_msg.clone();
165-
let publisher = subscriber_node
166-
.create_publisher::<std_msgs::msg::String>("topic", QOS_PROFILE_DEFAULT)?;
167-
let _subscription = subscriber_node.create_subscription::<std_msgs::msg::String, _>(
168-
"topic",
169-
QOS_PROFILE_DEFAULT,
170-
move |msg: std_msgs::msg::String| {
171-
let mut num_messages = n.lock().unwrap();
172-
let mut received_msg = m.lock().unwrap();
173-
174-
*num_messages += 1;
175-
*received_msg = msg.data;
176-
},
177-
)?;
178-
179-
let message = std_msgs::msg::String {
180-
data: String::from("Hello World"),
181-
};
182-
publisher.publish(message)?;
183-
spin_once(&subscriber_node, Some(Duration::from_millis(500)))?;
184-
185-
assert_eq!(*num_messages.lock().unwrap(), 1);
186-
assert_eq!(&*received_msg.lock().unwrap().as_str(), "Hello World");
187-
188-
Ok(())
189-
}
190-
}

rclrs/src/node.rs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -338,41 +338,3 @@ unsafe fn call_string_getter_with_handle(
338338
let cstr = CStr::from_ptr(char_ptr);
339339
cstr.to_string_lossy().into_owned()
340340
}
341-
342-
#[cfg(test)]
343-
mod tests {
344-
use super::*;
345-
use crate::{create_node, Context, Node, QOS_PROFILE_DEFAULT};
346-
347-
#[test]
348-
fn test_new() -> Result<(), RclrsError> {
349-
let context =
350-
Context::new(vec![]).expect("Context instantiation is expected to be a success");
351-
let _ = Node::new(&context, "Bob")?;
352-
353-
Ok(())
354-
}
355-
356-
#[test]
357-
fn test_create_subscription() -> Result<(), RclrsError> {
358-
let context =
359-
Context::new(vec![]).expect("Context instantiation is expected to be a success");
360-
let mut node = create_node(&context, "test_create_subscription")?;
361-
let _subscription = node.create_subscription::<std_msgs::msg::String, _>(
362-
"topic",
363-
QOS_PROFILE_DEFAULT,
364-
move |_: std_msgs::msg::String| {},
365-
)?;
366-
Ok(())
367-
}
368-
369-
#[test]
370-
fn test_create_publisher() -> Result<(), RclrsError> {
371-
let context =
372-
Context::new(vec![]).expect("Context instantiation is expected to be a success");
373-
let node = create_node(&context, "test_create_publisher")?;
374-
let _publisher =
375-
node.create_publisher::<std_msgs::msg::String>("topic", QOS_PROFILE_DEFAULT)?;
376-
Ok(())
377-
}
378-
}

rclrs/src/node/publisher.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -163,37 +163,3 @@ impl<'a, T: Message> MessageCow<'a, T> for &'a T {
163163
Cow::Borrowed(self)
164164
}
165165
}
166-
167-
#[cfg(test)]
168-
mod tests {
169-
use super::*;
170-
use crate::{create_node, Context, Publisher, QOS_PROFILE_DEFAULT};
171-
172-
fn create_fixture(name: &str) -> (Context, Node) {
173-
let context =
174-
Context::new(vec![]).expect("Context instantiation is expected to be a success");
175-
let node =
176-
create_node(&context, name).expect("Node instantiation is expected to be a success");
177-
178-
(context, node)
179-
}
180-
181-
#[test]
182-
fn test_new_publisher() -> Result<(), RclrsError> {
183-
let (_, node) = create_fixture("test_new_publisher");
184-
let _ = Publisher::<std_msgs::msg::String>::new(&node, "test", QOS_PROFILE_DEFAULT)?;
185-
186-
Ok(())
187-
}
188-
189-
#[test]
190-
fn test_publish_message() -> Result<(), RclrsError> {
191-
let (_, node) = create_fixture("test_publish_message");
192-
let publisher =
193-
Publisher::<std_msgs::msg::String>::new(&node, "test", QOS_PROFILE_DEFAULT)?;
194-
let message = std_msgs::msg::String {
195-
data: "Hello world!".to_owned(),
196-
};
197-
publisher.publish(&message)
198-
}
199-
}

rclrs/src/node/subscription.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -214,23 +214,3 @@ where
214214
Ok(())
215215
}
216216
}
217-
218-
#[cfg(test)]
219-
mod tests {
220-
use super::*;
221-
use crate::{create_node, Context, QOS_PROFILE_DEFAULT};
222-
223-
#[test]
224-
fn test_instantiate_subscriber() -> Result<(), RclrsError> {
225-
let context =
226-
Context::new(vec![]).expect("Context instantiation is expected to be a success");
227-
let mut node = create_node(&context, "test_new_subscriber")?;
228-
let _subscriber = node.create_subscription::<std_msgs::msg::String, _>(
229-
"test",
230-
QOS_PROFILE_DEFAULT,
231-
move |_: std_msgs::msg::String| {},
232-
)?;
233-
234-
Ok(())
235-
}
236-
}

rclrs/src/wait.rs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -289,42 +289,3 @@ impl WaitSet {
289289
Ok(ready_entities)
290290
}
291291
}
292-
293-
#[cfg(test)]
294-
mod tests {
295-
use crate::{Context, Node, RclrsError, WaitSet, QOS_PROFILE_DEFAULT};
296-
use std::sync::Arc;
297-
298-
#[test]
299-
fn test_adding_waitable_to_wait_sets() -> Result<(), RclrsError> {
300-
let context = Context::new([])?;
301-
let mut node = Node::new(&context, "test_adding_waitable_to_wait_sets")?;
302-
let subscription = node.create_subscription(
303-
"test",
304-
QOS_PROFILE_DEFAULT,
305-
move |_: std_msgs::msg::String| {},
306-
)?;
307-
let mut wait_set_1 = WaitSet::new(1, 0, 0, 0, 0, 0, &context)?;
308-
let mut wait_set_2 = WaitSet::new(1, 0, 0, 0, 0, 0, &context)?;
309-
310-
// Try to add the subscription to wait set 1 twice
311-
wait_set_1.add_subscription(Arc::clone(&subscription) as _)?;
312-
assert!(wait_set_1
313-
.add_subscription(Arc::clone(&subscription) as _)
314-
.is_err());
315-
316-
// Try to add it to another wait set
317-
assert!(wait_set_2
318-
.add_subscription(Arc::clone(&subscription) as _)
319-
.is_err());
320-
321-
// It works as soon as it is not anymore part of wait_set_1
322-
wait_set_1.clear();
323-
wait_set_2.add_subscription(Arc::clone(&subscription) as _)?;
324-
325-
// Dropping the wait set also frees up the subscription
326-
drop(wait_set_2);
327-
wait_set_1.add_subscription(Arc::clone(&subscription) as _)?;
328-
Ok(())
329-
}
330-
}

rosidl_runtime_rs/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
name = "rosidl_runtime_rs"
33
version = "0.2.0"
44
# This project is not military-sponsored, Jacob's employment contract just requires him to use this email address
5-
authors = ["Jacob Hassold <[email protected]>", "Nikolai Morin <[email protected]>"]
5+
authors = ["Esteve Fernandez <[email protected]>", "Nikolai Morin <[email protected]>", "Jacob Hassold <[email protected]>"]
66
edition = "2021"
7+
license = "Apache-2.0"
8+
description = "Message generation code shared by Rust projects in ROS 2"
79

810
[lib]
911
path = "src/lib.rs"

0 commit comments

Comments
 (0)