Skip to content

Commit

Permalink
refactor(fake_test_node): prefix package and namespace with autoware
Browse files Browse the repository at this point in the history
Signed-off-by: Esteve Fernandez <[email protected]>
  • Loading branch information
esteve committed Nov 13, 2024
1 parent 6a1ddbd commit cc4fc18
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ common/autoware_adapi_specs/** [email protected] [email protected]
common/autoware_auto_common/** [email protected] [email protected] [email protected] [email protected]
common/autoware_component_interface_specs/** [email protected] [email protected]
common/autoware_component_interface_tools/** [email protected]
common/autoware_fake_test_node/** [email protected] [email protected] [email protected] [email protected]
common/autoware_geography_utils/** [email protected]
common/autoware_goal_distance_calculator/** [email protected]
common/autoware_grid_map_utils/** [email protected]
Expand All @@ -27,7 +28,6 @@ common/autoware_universe_utils/** [email protected] [email protected]
common/autoware_vehicle_info_utils/** [email protected] [email protected] [email protected] [email protected]
common/bag_time_manager_rviz_plugin/** [email protected]
common/component_interface_utils/** [email protected] [email protected]
common/fake_test_node/** [email protected] [email protected] [email protected] [email protected]
common/global_parameter_loader/** [email protected]
common/glog_component/** [email protected]
common/tier4_adapi_rviz_plugin/** [email protected] [email protected] [email protected]
Expand Down
2 changes: 1 addition & 1 deletion common/.pages
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ nav:
- 'Introduction': common
- 'Testing Libraries':
- 'autoware_testing': common/autoware_testing/design/autoware_testing-design
- 'fake_test_node': common/fake_test_node/design/fake_test_node-design
- 'autoware_fake_test_node': common/autoware_fake_test_node/design/fake_test_node-design
- 'Test Utils': common/autoware_test_utils
- 'Common Libraries':
- 'autoware_auto_common':
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
cmake_minimum_required(VERSION 3.14)
project(fake_test_node)
project(autoware_fake_test_node)

find_package(autoware_cmake REQUIRED)
autoware_package()

ament_auto_add_library(fake_test_node SHARED src/fake_test_node.cpp)
ament_auto_add_library(${PROJECT_NAME} SHARED src/fake_test_node.cpp)

if(BUILD_TESTING)
ament_add_ros_isolated_gtest(test_fake_test_node
test/test_fake_test_node.cpp
)
add_dependencies(test_fake_test_node fake_test_node)
target_link_libraries(test_fake_test_node fake_test_node)
add_dependencies(test_fake_test_node ${PROJECT_NAME})
target_link_libraries(test_fake_test_node ${PROJECT_NAME})
endif()

ament_auto_package()
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ fixture.
This package contains a library that introduces two utility classes that can be used in place of
custom fixtures described above to write integration tests for a node:

- `autoware::tools::testing::FakeTestNode` - to use as a custom test fixture with `TEST_F` tests
- `autoware::tools::testing::FakeTestNodeParametrized` - to use a custom test fixture with the
- `autoware::fake_test_node::FakeTestNode` - to use as a custom test fixture with `TEST_F` tests
- `autoware::fake_test_node::FakeTestNodeParametrized` - to use a custom test fixture with the
parametrized `TEST_P` tests (accepts a template parameter that gets forwarded to
`testing::TestWithParam<T>`)

Expand All @@ -30,10 +30,10 @@ Let's say there is a node `NodeUnderTest` that requires testing. It just
subscribes to `std_msgs::msg::Int32` messages and publishes a
`std_msgs::msg::Bool` to indicate that the input is positive. To test such a
node the following code can be used utilizing the
`autoware::tools::testing::FakeTestNode`:
`autoware::fake_test_node::FakeTestNode`:

```cpp
using FakeNodeFixture = autoware::tools::testing::FakeTestNode;
using FakeNodeFixture = autoware::fake_test_node::FakeTestNode;

/// @test Test that we can use a non-parametrized test.
TEST_F(FakeNodeFixture, Test) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
/// \copyright Copyright 2021 Apex.AI, Inc.
/// All rights reserved.

#ifndef FAKE_TEST_NODE__FAKE_TEST_NODE_HPP_
#define FAKE_TEST_NODE__FAKE_TEST_NODE_HPP_
#ifndef AUTOWARE__FAKE_TEST_NODE__FAKE_TEST_NODE_HPP_
#define AUTOWARE__FAKE_TEST_NODE__FAKE_TEST_NODE_HPP_

#include <fake_test_node/visibility_control.hpp>
#include <autoware/fake_test_node/visibility_control.hpp>
#include <rclcpp/rclcpp.hpp>

#include <gtest/gtest.h>
Expand All @@ -30,11 +30,7 @@
#include <string>
#include <type_traits>

namespace autoware
{
namespace tools
{
namespace testing
namespace autoware::fake_test_node
{

///
Expand Down Expand Up @@ -237,8 +233,6 @@ class FAKE_TEST_NODE_PUBLIC FakeTestNode : public detail::FakeNodeCore, public :
void TearDown() override;
};

} // namespace testing
} // namespace tools
} // namespace autoware
} // namespace autoware::fake_test_node

#endif // FAKE_TEST_NODE__FAKE_TEST_NODE_HPP_
#endif // AUTOWARE__FAKE_TEST_NODE__FAKE_TEST_NODE_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
/// \copyright Copyright 2021 Apex.AI, Inc.
/// All rights reserved.

#ifndef FAKE_TEST_NODE__VISIBILITY_CONTROL_HPP_
#define FAKE_TEST_NODE__VISIBILITY_CONTROL_HPP_
#ifndef AUTOWARE__FAKE_TEST_NODE__VISIBILITY_CONTROL_HPP_
#define AUTOWARE__FAKE_TEST_NODE__VISIBILITY_CONTROL_HPP_

////////////////////////////////////////////////////////////////////////////////
#if defined(__WIN32)
Expand All @@ -39,4 +39,4 @@
#error "Unsupported Build Configuration"
#endif // defined(__WIN32)

#endif // FAKE_TEST_NODE__VISIBILITY_CONTROL_HPP_
#endif // AUTOWARE__FAKE_TEST_NODE__VISIBILITY_CONTROL_HPP_
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>fake_test_node</name>
<name>autoware_fake_test_node</name>
<version>0.38.0</version>
<description>A fake node that we can use in the integration-like cpp tests.</description>
<maintainer email="[email protected]">Apex.AI, Inc.</maintainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
/// \copyright Copyright 2021 Apex.AI, Inc.
/// All rights reserved.

#include <fake_test_node/fake_test_node.hpp>
#include <autoware/fake_test_node/fake_test_node.hpp>

#include <memory>
#include <string>

namespace
namespace autoware::fake_test_node
{
constexpr auto kSpinThread = false;
constexpr auto kArgc = 0;
Expand All @@ -34,15 +34,6 @@ std::string sanitize_test_name(const std::string & name)
return sanitize_test_name;
}

} // namespace

namespace autoware
{
namespace tools
{
namespace testing
{

void detail::FakeNodeCore::set_up(const std::string & test_name)
{
ASSERT_FALSE(rclcpp::ok());
Expand Down Expand Up @@ -76,6 +67,4 @@ void FakeTestNode::TearDown()
tear_down();
}

} // namespace testing
} // namespace tools
} // namespace autoware
} // namespace autoware::fake_test_node
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/// \copyright Copyright 2021 Apex.AI, Inc.
/// All rights reserved.

#include <fake_test_node/fake_test_node.hpp>
#include <autoware/fake_test_node/fake_test_node.hpp>

#include <std_msgs/msg/bool.hpp>
#include <std_msgs/msg/int32.hpp>
Expand All @@ -30,8 +30,8 @@

using bool8_t = bool;

using FakeNodeFixture = autoware::tools::testing::FakeTestNode;
using FakeNodeFixtureParametrized = autoware::tools::testing::FakeTestNodeParametrized<bool8_t>;
using FakeNodeFixture = autoware::fake_test_node::FakeTestNode;
using FakeNodeFixtureParametrized = autoware::fake_test_node::FakeTestNodeParametrized<bool8_t>;
using std_msgs::msg::Bool;
using std_msgs::msg::Int32;

Expand Down
2 changes: 1 addition & 1 deletion control/autoware_trajectory_follower_node/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
<test_depend>ament_index_cpp</test_depend>
<test_depend>ament_index_python</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>autoware_fake_test_node</test_depend>
<test_depend>autoware_lint_common</test_depend>
<test_depend>autoware_testing</test_depend>
<test_depend>fake_test_node</test_depend>
<test_depend>ros_testing</test_depend>

<export>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.

#include "ament_index_cpp/get_package_share_directory.hpp"
#include "autoware/fake_test_node/fake_test_node.hpp"
#include "autoware/trajectory_follower_node/controller_node.hpp"
#include "fake_test_node/fake_test_node.hpp"
#include "gtest/gtest.h"
#include "rclcpp/rclcpp.hpp"
#include "rclcpp/time.hpp"
Expand Down Expand Up @@ -42,7 +42,7 @@ using SteeringReport = autoware_vehicle_msgs::msg::SteeringReport;
using autoware_adapi_v1_msgs::msg::OperationModeState;
using geometry_msgs::msg::AccelWithCovarianceStamped;

using FakeNodeFixture = autoware::tools::testing::FakeTestNode;
using FakeNodeFixture = autoware::fake_test_node::FakeTestNode;

const rclcpp::Duration one_second(1, 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#ifndef TRAJECTORY_FOLLOWER_TEST_UTILS_HPP_
#define TRAJECTORY_FOLLOWER_TEST_UTILS_HPP_

#include "fake_test_node/fake_test_node.hpp"
#include "autoware/fake_test_node/fake_test_node.hpp"
#include "rclcpp/rclcpp.hpp"
#include "rclcpp/time.hpp"
#include "tf2_ros/static_transform_broadcaster.h"
Expand All @@ -27,7 +27,7 @@

namespace test_utils
{
using FakeNodeFixture = autoware::tools::testing::FakeTestNode;
using FakeNodeFixture = autoware::fake_test_node::FakeTestNode;

inline void waitForMessage(
const std::shared_ptr<rclcpp::Node> & node, FakeNodeFixture * fixture, const bool & received_flag,
Expand Down
2 changes: 1 addition & 1 deletion planning/autoware_path_optimizer/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
<test_depend>ament_cmake_ros</test_depend>
<test_depend>ament_index_python</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>autoware_fake_test_node</test_depend>
<test_depend>autoware_lint_common</test_depend>
<test_depend>autoware_testing</test_depend>
<test_depend>fake_test_node</test_depend>

<export>
<build_type>ament_cmake</build_type>
Expand Down
2 changes: 1 addition & 1 deletion planning/autoware_path_smoother/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
<test_depend>ament_cmake_ros</test_depend>
<test_depend>ament_index_python</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>autoware_fake_test_node</test_depend>
<test_depend>autoware_lint_common</test_depend>
<test_depend>autoware_testing</test_depend>
<test_depend>fake_test_node</test_depend>

<export>
<build_type>ament_cmake</build_type>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
<test_depend>ament_cmake_ros</test_depend>
<test_depend>ament_index_python</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>autoware_fake_test_node</test_depend>
<test_depend>autoware_lint_common</test_depend>
<test_depend>autoware_testing</test_depend>
<test_depend>fake_test_node</test_depend>

<export>
<build_type>ament_cmake</build_type>
Expand Down

0 comments on commit cc4fc18

Please sign in to comment.