Skip to content

Commit db6a6ac

Browse files
committed
Fix #408: debugMessage shows type info for remapped subtree entries
1 parent b3dbe30 commit db6a6ac

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

src/blackboard.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,21 @@ void Blackboard::debugMessage() const
116116

117117
for(const auto& [from, to] : internal_to_external_)
118118
{
119-
std::cout << "[" << from << "] remapped to port of parent tree [" << to << "]"
120-
<< std::endl;
119+
std::cout << "[" << from << "] remapped to port of parent tree [" << to << "]";
120+
// Show the type of the remapped entry from the parent. Issue #408.
121+
if(auto parent = parent_bb_.lock())
122+
{
123+
if(auto entry = parent->getEntry(to))
124+
{
125+
auto port_type = entry->info.type();
126+
if(port_type == typeid(void))
127+
{
128+
port_type = entry->value.type();
129+
}
130+
std::cout << " (" << BT::demangle(port_type) << ")";
131+
}
132+
}
133+
std::cout << std::endl;
121134
}
122135
}
123136

tests/gtest_blackboard.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,3 +745,31 @@ TEST(BlackboardTest, SetBlackboard_WithPortRemapping)
745745
// Tick till the end with no crashes
746746
ASSERT_NO_THROW(tree.tickWhileRunning(););
747747
}
748+
749+
// Issue #408: debugMessage should show remapped entries from parent blackboard
750+
TEST(BlackboardTest, DebugMessageShowsRemappedEntries_Issue408)
751+
{
752+
// Create parent BB with a value
753+
auto parent_bb = Blackboard::create();
754+
parent_bb->set("parent_value", 42);
755+
756+
// Create child BB with remapping
757+
auto child_bb = Blackboard::create(parent_bb);
758+
child_bb->addSubtreeRemapping("local_name", "parent_value");
759+
760+
// Capture debugMessage output
761+
testing::internal::CaptureStdout();
762+
child_bb->debugMessage();
763+
std::string output = testing::internal::GetCapturedStdout();
764+
765+
// The output should contain the remapped key with its type info from parent
766+
EXPECT_TRUE(output.find("local_name") != std::string::npos)
767+
<< "debugMessage output should mention 'local_name'. Got: " << output;
768+
EXPECT_TRUE(output.find("parent_value") != std::string::npos)
769+
<< "debugMessage output should mention 'parent_value'. Got: " << output;
770+
// The output should show the parent entry's type, not just the remapping
771+
EXPECT_TRUE(output.find("int") != std::string::npos) << "debugMessage output should "
772+
"show the type of the remapped "
773+
"entry. Got: "
774+
<< output;
775+
}

0 commit comments

Comments
 (0)