From b913c8939297710742f0f47e1219f6a1556157ee Mon Sep 17 00:00:00 2001 From: Pepe Date: Thu, 2 Apr 2026 22:52:12 +0100 Subject: [PATCH 1/3] Enhances TestNode with script-based return status and conditional post-scripts Introduces `return_status_script` to allow dynamic computation of the TestNode's completion status based on blackboard variables at runtime. This provides greater flexibility for mocking different scenarios in tests. Refines post-execution logic by replacing a single `post_script` with distinct `success_script` and `failure_script` that execute based on the TestNode's final status. The `return_status_script` takes precedence over a statically defined `return_status`. Adds comprehensive validation to prevent the TestNode from returning an `IDLE` status and to ensure a valid completion status mechanism is always configured. --- examples/CMakeLists.txt | 1 + examples/t15_nodes_mocking.cpp | 46 +++-- examples/t15_nodes_mocking_strict_failure.cpp | 145 +++++++++++++++ include/behaviortree_cpp/actions/test_node.h | 31 +++- src/actions/test_node.cpp | 107 +++++++++++- src/bt_factory.cpp | 18 +- tests/gtest_substitution.cpp | 165 +++++++++++++++++- 7 files changed, 484 insertions(+), 29 deletions(-) create mode 100644 examples/t15_nodes_mocking_strict_failure.cpp diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 9a94c95e8..7ccb5f05d 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -35,6 +35,7 @@ CompileExample("t12_default_ports") CompileExample("t13_access_by_ref") CompileExample("t14_subtree_model") CompileExample("t15_nodes_mocking") +CompileExample("t15_nodes_mocking_strict_failure") CompileExample("t16_global_blackboard") CompileExample("t17_blackboard_backup") CompileExample("t18_waypoints") diff --git a/examples/t15_nodes_mocking.cpp b/examples/t15_nodes_mocking.cpp index 805a46b95..78d276872 100644 --- a/examples/t15_nodes_mocking.cpp +++ b/examples/t15_nodes_mocking.cpp @@ -14,8 +14,14 @@ const char* xml_text = R"( -