Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(planning_test_utils): add ASSART_NO_THROW_WITH_ERROR_MSG macro #3695

Merged
merged 3 commits into from
May 16, 2023

Conversation

TakaHoribe
Copy link
Contributor

@TakaHoribe TakaHoribe commented May 12, 2023

Description

since ASSERT_NO_THROW in gtest masks the exception message, I redefine it with error message.

Before

3: /home/horibe/workspace/pilot-auto.latest/src/autoware/universe/planning/behavior_velocity_planner/test/src/test_behavior_velocity_planner_node_interface.cpp:169: Failure
3: Expected: test_manager->testOffTrackFromPathWithLaneId(test_target_node) doesn't throw an exception.
3: Actual: it throws. 

After

3: /home/horibe/workspace/pilot-auto.latest/src/autoware/universe/planning/behavior_velocity_planner/test/src/test_behavior_velocity_planner_node_interface.cpp:153: Failure
3: Failed
3: Expected: test_manager->testOffTrackFromPathWithLaneId(test_target_node) doesn't throw an exception.
3: Actual: it throws. Error message: Topic name for N8nav_msgs3msg9Odometry_ISaIvEEE is empty

Tests performed

run colcon test for planning packages

Effects on system behavior

None

Pre-review checklist for the PR author

The PR author must check the checkboxes below when creating the PR.

In-review checklist for the PR reviewers

The PR reviewers must check the checkboxes below before approval.

Post-review checklist for the PR author

The PR author must check the checkboxes below before merging.

  • There are no open discussions or they are tracked via tickets.

After all checkboxes are checked, anyone who has write access can merge the PR.

@github-actions github-actions bot added the component:planning Route planning, decision-making, and navigation. (auto-assigned) label May 12, 2023
@codecov
Copy link

codecov bot commented May 12, 2023

Codecov Report

Patch coverage has no change and project coverage change: +0.99 🎉

Comparison is base (a54ad62) 14.55% compared to head (2541234) 15.55%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3695      +/-   ##
==========================================
+ Coverage   14.55%   15.55%   +0.99%     
==========================================
  Files        1409     1303     -106     
  Lines       99287    92685    -6602     
  Branches    29347    29349       +2     
==========================================
- Hits        14455    14420      -35     
+ Misses      69245    62682    -6563     
+ Partials    15587    15583       -4     
Flag Coverage Δ *Carryforward flag
differential 16.19% <0.00%> (?)
total 15.00% <ø> (+0.44%) ⬆️ Carriedforward from e09d02e

*This pull request uses carry forward flags. Click here to find out more.

Impacted Files Coverage Δ
...test/test_behavior_path_planner_node_interface.cpp 27.90% <0.00%> (ø)
.../test_behavior_velocity_planner_node_interface.cpp 19.67% <0.00%> (ø)
...ner/test/test_freespace_planner_node_interface.cpp 32.43% <0.00%> (ø)
...test_obstacle_avoidance_planner_node_interface.cpp 14.28% <0.00%> (ø)
...st/test_obstacle_cruise_planner_node_interface.cpp 34.28% <0.00%> (ø)
...test/test_obstacle_stop_planner_node_interface.cpp 31.57% <0.00%> (ø)
..._manager/planning_interface_test_manager_utils.hpp 11.11% <0.00%> (-0.16%) ⬇️

... and 110 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Signed-off-by: Takamasa Horibe <horibe.takamasa@gmail.com>
Signed-off-by: Takamasa Horibe <horibe.takamasa@gmail.com>
@kyoichi-sugahara
Copy link
Contributor

awesome!
I could get an error with following change

diff --git a/planning/behavior_path_planner/test/test_behavior_path_planner_node_interface.cpp b/planning/behavior_path_planner/test/test_behavior_path_planner_node_interface.cpp
index a24086a3df..4ec1340d45 100644
--- a/planning/behavior_path_planner/test/test_behavior_path_planner_node_interface.cpp
+++ b/planning/behavior_path_planner/test/test_behavior_path_planner_node_interface.cpp
@@ -86,7 +86,7 @@ void publishMandatoryTopics(
   test_manager->publishCostMap(test_target_node, "behavior_path_planner/input/costmap");
   test_manager->publishOperationModeState(test_target_node, "system/operation_mode/state");
   test_manager->publishLateralOffset(
-    test_target_node, "behavior_path_planner/input/lateral_offset");
+    test_target_node, "");
 }
 
 TEST(PlanningModuleInterfaceTest, NodeTestWithExceptionRoute)

error is like this

6: C++ exception with description "Topic name for N19tier4_planning_msgs3msg14LateralOffset_ISaIvEEE is empty" thrown in the test body.

so it's a little bit annoying so by changing this

diff --git a/planning/planning_test_utils/include/planning_interface_test_manager/planning_interface_test_manager_utils.hpp b/planning/planning_test_utils/include/planning_interface_test_manager/planning_interface_test_manager_utils.hpp
index b0d738b127..15ff71b1e9 100644
--- a/planning/planning_test_utils/include/planning_interface_test_manager/planning_interface_test_manager_utils.hpp
+++ b/planning/planning_test_utils/include/planning_interface_test_manager/planning_interface_test_manager_utils.hpp
@@ -41,6 +41,7 @@
 
 #include <boost/optional.hpp>
 
+#include <cxxabi.h>
 #include <lanelet2_io/Io.h>
 #include <tf2/utils.h>
 #include <tf2_ros/buffer.h>
@@ -358,7 +359,13 @@ void publishToTargetNode(
   typename rclcpp::Publisher<T>::SharedPtr publisher, T data, const int repeat_count = 3)
 {
   if (topic_name.empty()) {
-    throw std::runtime_error(std::string("Topic name for ") + typeid(data).name() + " is empty");
+    int status;
+    char * demangled_name = abi::__cxa_demangle(typeid(data).name(), nullptr, nullptr, &status);
+    if (status == 0) {
+      throw std::runtime_error(std::string("Topic name for ") + demangled_name + " is empty");
+    } else {
+      throw std::runtime_error(std::string("Topic name for ") + typeid(data).name() + " is empty");
+    }
   }
 
   test_utils::setPublisher<T>(test_node, topic_name, publisher);

I could get an error like below.

C++ exception with description "Topic name for tier4_planning_msgs::msg::LateralOffset_<std::allocator<void> > is empty" thrown in the test body.

Signed-off-by: Takamasa Horibe <horibe.takamasa@gmail.com>
Copy link
Contributor

@kyoichi-sugahara kyoichi-sugahara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!!

@TakaHoribe TakaHoribe enabled auto-merge (squash) May 13, 2023 11:33
@TakaHoribe TakaHoribe disabled auto-merge May 13, 2023 11:33
@TakaHoribe TakaHoribe enabled auto-merge (squash) May 13, 2023 11:34
@TakaHoribe TakaHoribe disabled auto-merge May 16, 2023 04:36
@TakaHoribe TakaHoribe merged commit c308a79 into autowarefoundation:main May 16, 2023
@TakaHoribe TakaHoribe deleted the show-debug-msg branch May 16, 2023 04:40
kyoichi-sugahara pushed a commit to kyoichi-sugahara/autoware.universe that referenced this pull request May 16, 2023
…utowarefoundation#3695)

* test(planning_test_utils): add ASSART_NO_THROW_WITH_ERROR_MSG macro

Signed-off-by: Takamasa Horibe <horibe.takamasa@gmail.com>

* update for behavior_velocity_planner

Signed-off-by: Takamasa Horibe <horibe.takamasa@gmail.com>

* fix for exception error msg

Signed-off-by: Takamasa Horibe <horibe.takamasa@gmail.com>

---------

Signed-off-by: Takamasa Horibe <horibe.takamasa@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:planning Route planning, decision-making, and navigation. (auto-assigned)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants