@@ -483,8 +483,7 @@ class TestWaitable : public rclcpp::Waitable
483483 }
484484 }
485485
486- if (hold_execute)
487- {
486+ if (hold_execute) {
488487 std::unique_lock<std::mutex> lk (cv_m);
489488 cv.wait (lk);
490489 }
@@ -554,9 +553,16 @@ TYPED_TEST(TestExecutors, spinAll)
554553 // Long timeout, but should not block test if spin_all works as expected as we cancel the
555554 // executor.
556555 bool spin_exited = false ;
557- std::thread spinner ([&spin_exited, &executor, this ]() {
558- executor.spin_all (1s);
559- executor.remove_node (this ->node , true );
556+ std::atomic_bool exception = false ;
557+
558+ std::thread spinner ([&spin_exited, &executor, &exception, this ]() {
559+ try {
560+ executor.spin_all (1s);
561+ executor.remove_node (this ->node , true );
562+ } catch (...) {
563+ exception = true ;
564+ }
565+
560566 spin_exited = true ;
561567 });
562568
@@ -581,6 +587,8 @@ TYPED_TEST(TestExecutors, spinAll)
581587 EXPECT_LT (1u , my_waitable->get_count ());
582588 waitable_interfaces->remove_waitable (my_waitable, nullptr );
583589 ASSERT_TRUE (spin_exited);
590+
591+ EXPECT_FALSE (exception);
584592 spinner.join ();
585593}
586594
@@ -863,9 +871,16 @@ TYPED_TEST(TestExecutors, spinSome)
863871 // Long timeout, doesn't block test from finishing because spin_some should exit after the
864872 // first one completes.
865873 bool spin_exited = false ;
866- std::thread spinner ([&spin_exited, &executor, this ]() {
867- executor.spin_some (1s);
868- executor.remove_node (this ->node , true );
874+
875+ std::atomic_bool exception = false ;
876+
877+ std::thread spinner ([&spin_exited, &executor, &exception, this ]() {
878+ try {
879+ executor.spin_some (1s);
880+ executor.remove_node (this ->node , true );
881+ } catch (...) {
882+ exception = true ;
883+ }
869884 spin_exited = true ;
870885 });
871886
@@ -886,6 +901,7 @@ TYPED_TEST(TestExecutors, spinSome)
886901 EXPECT_LE (1u , my_waitable->get_count ());
887902 waitable_interfaces->remove_waitable (my_waitable, nullptr );
888903 EXPECT_TRUE (spin_exited);
904+ EXPECT_FALSE (exception);
889905 // Cancel if it hasn't exited already.
890906 executor.cancel ();
891907
0 commit comments