Skip to content

Commit

Permalink
Compile tests (ros2#103)
Browse files Browse the repository at this point in the history
* move process helper to test_common

Signed-off-by: Karsten Knese <karsten@openrobotics.org>

* use stdexcept for runtime error

Signed-off-by: Karsten Knese <karsten@openrobotics.org>

* always install include directories

Signed-off-by: Karsten Knese <karsten@openrobotics.org>
  • Loading branch information
Karsten1987 authored Apr 27, 2019
1 parent b108fb4 commit f731271
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 29 deletions.
1 change: 1 addition & 0 deletions rosbag2/src/rosbag2/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "rosbag2/converter.hpp"

#include <memory>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>
Expand Down
1 change: 1 addition & 0 deletions rosbag2/src/rosbag2/info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "rosbag2/info.hpp"

#include <memory>
#include <stdexcept>
#include <string>

#include "rosbag2_storage/filesystem_helper.hpp"
Expand Down
1 change: 1 addition & 0 deletions rosbag2/src/rosbag2/sequential_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "rosbag2/sequential_reader.hpp"

#include <memory>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "rosbag2/serialization_format_converter_factory_interface.hpp"

#include <memory>
#include <stdexcept>
#include <string>
#include <vector>

Expand Down
1 change: 1 addition & 0 deletions rosbag2/src/rosbag2/typesupport_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "rosbag2/typesupport_helpers.hpp"

#include <memory>
#include <stdexcept>
#include <string>
#include <utility>

Expand Down
1 change: 1 addition & 0 deletions rosbag2/src/rosbag2/writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "rosbag2/writer.hpp"

#include <memory>
#include <stdexcept>
#include <string>
#include <utility>

Expand Down
30 changes: 14 additions & 16 deletions rosbag2_test_common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,25 @@ endif()

find_package(ament_cmake REQUIRED)

if(BUILD_TESTING)
find_package(ament_cmake_gmock REQUIRED)
find_package(ament_lint_auto REQUIRED)
find_package(rclcpp REQUIRED)
find_package(ament_cmake_gmock REQUIRED)
find_package(ament_lint_auto REQUIRED)
find_package(rclcpp REQUIRED)

ament_lint_auto_find_test_dependencies()
ament_lint_auto_find_test_dependencies()

add_library(${PROJECT_NAME} INTERFACE)
add_library(${PROJECT_NAME} INTERFACE)

target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

target_link_libraries(${PROJECT_NAME} INTERFACE rclcpp rcutils)
target_link_libraries(${PROJECT_NAME} INTERFACE rclcpp rcutils)

ament_export_dependencies(rclcpp)
ament_export_include_directories(include)
ament_export_dependencies(rclcpp)

install(
DIRECTORY include/
DESTINATION include)
endif()
install(
DIRECTORY include/
DESTINATION include)

ament_export_include_directories(include)
ament_package()
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef ROSBAG2_TESTS__PROCESS_EXECUTION_HELPERS_HPP_
#define ROSBAG2_TESTS__PROCESS_EXECUTION_HELPERS_HPP_
#ifndef ROSBAG2_TEST_COMMON__PROCESS_EXECUTION_HELPERS_HPP_
#define ROSBAG2_TEST_COMMON__PROCESS_EXECUTION_HELPERS_HPP_

#ifdef _WIN32
#include "process_execution_helpers_windows.hpp"
#else
#include "process_execution_helpers_unix.hpp"
#endif

#endif // ROSBAG2_TESTS__PROCESS_EXECUTION_HELPERS_HPP_
#endif // ROSBAG2_TEST_COMMON__PROCESS_EXECUTION_HELPERS_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef ROSBAG2_TESTS__PROCESS_EXECUTION_HELPERS_UNIX_HPP_
#define ROSBAG2_TESTS__PROCESS_EXECUTION_HELPERS_UNIX_HPP_
#ifndef ROSBAG2_TEST_COMMON__PROCESS_EXECUTION_HELPERS_UNIX_HPP_
#define ROSBAG2_TEST_COMMON__PROCESS_EXECUTION_HELPERS_UNIX_HPP_

#include <gmock/gmock.h>

Expand Down Expand Up @@ -69,4 +69,4 @@ void stop_execution(const ProcessHandle & handle)
EXPECT_THAT(WEXITSTATUS(child_return_code), Not(Eq(EXIT_FAILURE)));
}

#endif // ROSBAG2_TESTS__PROCESS_EXECUTION_HELPERS_UNIX_HPP_
#endif // ROSBAG2_TEST_COMMON__PROCESS_EXECUTION_HELPERS_UNIX_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef ROSBAG2_TESTS__PROCESS_EXECUTION_HELPERS_WINDOWS_HPP_
#define ROSBAG2_TESTS__PROCESS_EXECUTION_HELPERS_WINDOWS_HPP_
#ifndef ROSBAG2_TEST_COMMON__PROCESS_EXECUTION_HELPERS_WINDOWS_HPP_
#define ROSBAG2_TEST_COMMON__PROCESS_EXECUTION_HELPERS_WINDOWS_HPP_

#include <gmock/gmock.h>

Expand Down Expand Up @@ -115,4 +115,4 @@ void stop_execution(const ProcessHandle & handle)
CloseHandle(handle.job_handle);
}

#endif // ROSBAG2_TESTS__PROCESS_EXECUTION_HELPERS_WINDOWS_HPP_
#endif // ROSBAG2_TEST_COMMON__PROCESS_EXECUTION_HELPERS_WINDOWS_HPP_
3 changes: 2 additions & 1 deletion rosbag2_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ if(BUILD_TESTING)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
if(TARGET test_rosbag2_info_end_to_end)
ament_target_dependencies(test_rosbag2_info_end_to_end
rosbag2_storage)
rosbag2_storage
rosbag2_test_common)
endif()

ament_add_gmock(test_converter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <string>
#include <thread>

#include "process_execution_helpers.hpp"
#include "rosbag2_test_common/process_execution_helpers.hpp"

using namespace ::testing; // NOLINT

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

// rclcpp must be included before process_execution_helpers.hpp
#include "rclcpp/rclcpp.hpp"
#include "process_execution_helpers.hpp"
#include "rosbag2_test_common/process_execution_helpers.hpp"

#include "test_msgs/msg/primitives.hpp"
#include "test_msgs/msg/static_array_primitives.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

// rclcpp.hpp included in record_fixture.hpp must be included before process_execution_helpers.hpp
#include "record_fixture.hpp"
#include "process_execution_helpers.hpp"
#include "rosbag2_test_common/process_execution_helpers.hpp"
#include "rosbag2_storage/metadata_io.hpp"

TEST_F(RecordFixture, record_end_to_end_test) {
Expand Down

0 comments on commit f731271

Please sign in to comment.