Skip to content

Commit

Permalink
Test nested subsystem naming
Browse files Browse the repository at this point in the history
  • Loading branch information
girstenbrei committed Jan 10, 2025
1 parent 4602be1 commit 8f3eff5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/subsystem/subsystem_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ impl<ErrType: ErrTypeTraits> SubsystemHandle<ErrType> {
///
/// Note that the names of nested subsystems are built unix-path alike,
/// starting and delimited by slashes (e.g. `/a/b/c`).
///
///
/// See [`SubsystemBuilder::new()`] how to set this name.
pub fn name(&self) -> &str {
&self.inner.name
Expand Down
12 changes: 9 additions & 3 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -924,13 +924,19 @@ async fn shutdown_through_signal() {
#[tokio::test]
#[traced_test]
async fn access_name_from_within_subsystem() {
let subsys1 = move |subsys: SubsystemHandle| async move {
assert_eq!("/subsys", subsys.name());
let subsys_nested = move |subsys: SubsystemHandle| async move {
assert_eq!("/subsys_top/subsys_nested", subsys.name());
BoxedResult::Ok(())
};

let subsys_top = move |subsys: SubsystemHandle| async move {
assert_eq!("/subsys_top", subsys.name());
subsys.start(SubsystemBuilder::new("subsys_nested", subsys_nested));
BoxedResult::Ok(())
};

Toplevel::new(move |s| async move {
s.start(SubsystemBuilder::new("subsys", subsys1));
s.start(SubsystemBuilder::new("subsys_top", subsys_top));
})
.handle_shutdown_requests(Duration::from_millis(100))
.await
Expand Down

0 comments on commit 8f3eff5

Please sign in to comment.