From de6bb54bb959124b5d543954237ebd0c0ed71761 Mon Sep 17 00:00:00 2001 From: TaikiYamada4 Date: Wed, 25 Dec 2024 15:36:15 +0900 Subject: [PATCH 1/2] Categorize test codes Signed-off-by: TaikiYamada4 --- .../test_missing_regulatory_elements_for_crosswalks.cpp | 0 .../test_regulatory_elements_details_for_crosswalks.cpp | 0 .../test/src/{ => include}/map_validation_tester.hpp | 0 .../test_intersection_area_dangling_reference.cpp | 0 .../{ => intersection}/test_intersection_area_segment_type.cpp | 0 .../src/{ => intersection}/test_intersection_area_validity.cpp | 0 .../test_missing_regulatory_elements_for_stop_lines.cpp | 0 .../test_missing_referrers_for_traffic_lights.cpp | 0 .../test_missing_regulatory_elements_for_traffic_lights.cpp | 0 .../test_regulatory_elements_details_for_traffic_lights.cpp | 0 .../test/src/{ => traffic_light}/test_traffic_light_facing.cpp | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename map/autoware_lanelet2_map_validator/test/src/{ => crosswalk}/test_missing_regulatory_elements_for_crosswalks.cpp (100%) rename map/autoware_lanelet2_map_validator/test/src/{ => crosswalk}/test_regulatory_elements_details_for_crosswalks.cpp (100%) rename map/autoware_lanelet2_map_validator/test/src/{ => include}/map_validation_tester.hpp (100%) rename map/autoware_lanelet2_map_validator/test/src/{ => intersection}/test_intersection_area_dangling_reference.cpp (100%) rename map/autoware_lanelet2_map_validator/test/src/{ => intersection}/test_intersection_area_segment_type.cpp (100%) rename map/autoware_lanelet2_map_validator/test/src/{ => intersection}/test_intersection_area_validity.cpp (100%) rename map/autoware_lanelet2_map_validator/test/src/{ => stop_line}/test_missing_regulatory_elements_for_stop_lines.cpp (100%) rename map/autoware_lanelet2_map_validator/test/src/{ => traffic_light}/test_missing_referrers_for_traffic_lights.cpp (100%) rename map/autoware_lanelet2_map_validator/test/src/{ => traffic_light}/test_missing_regulatory_elements_for_traffic_lights.cpp (100%) rename map/autoware_lanelet2_map_validator/test/src/{ => traffic_light}/test_regulatory_elements_details_for_traffic_lights.cpp (100%) rename map/autoware_lanelet2_map_validator/test/src/{ => traffic_light}/test_traffic_light_facing.cpp (100%) diff --git a/map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements_for_crosswalks.cpp b/map/autoware_lanelet2_map_validator/test/src/crosswalk/test_missing_regulatory_elements_for_crosswalks.cpp similarity index 100% rename from map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements_for_crosswalks.cpp rename to map/autoware_lanelet2_map_validator/test/src/crosswalk/test_missing_regulatory_elements_for_crosswalks.cpp diff --git a/map/autoware_lanelet2_map_validator/test/src/test_regulatory_elements_details_for_crosswalks.cpp b/map/autoware_lanelet2_map_validator/test/src/crosswalk/test_regulatory_elements_details_for_crosswalks.cpp similarity index 100% rename from map/autoware_lanelet2_map_validator/test/src/test_regulatory_elements_details_for_crosswalks.cpp rename to map/autoware_lanelet2_map_validator/test/src/crosswalk/test_regulatory_elements_details_for_crosswalks.cpp diff --git a/map/autoware_lanelet2_map_validator/test/src/map_validation_tester.hpp b/map/autoware_lanelet2_map_validator/test/src/include/map_validation_tester.hpp similarity index 100% rename from map/autoware_lanelet2_map_validator/test/src/map_validation_tester.hpp rename to map/autoware_lanelet2_map_validator/test/src/include/map_validation_tester.hpp diff --git a/map/autoware_lanelet2_map_validator/test/src/test_intersection_area_dangling_reference.cpp b/map/autoware_lanelet2_map_validator/test/src/intersection/test_intersection_area_dangling_reference.cpp similarity index 100% rename from map/autoware_lanelet2_map_validator/test/src/test_intersection_area_dangling_reference.cpp rename to map/autoware_lanelet2_map_validator/test/src/intersection/test_intersection_area_dangling_reference.cpp diff --git a/map/autoware_lanelet2_map_validator/test/src/test_intersection_area_segment_type.cpp b/map/autoware_lanelet2_map_validator/test/src/intersection/test_intersection_area_segment_type.cpp similarity index 100% rename from map/autoware_lanelet2_map_validator/test/src/test_intersection_area_segment_type.cpp rename to map/autoware_lanelet2_map_validator/test/src/intersection/test_intersection_area_segment_type.cpp diff --git a/map/autoware_lanelet2_map_validator/test/src/test_intersection_area_validity.cpp b/map/autoware_lanelet2_map_validator/test/src/intersection/test_intersection_area_validity.cpp similarity index 100% rename from map/autoware_lanelet2_map_validator/test/src/test_intersection_area_validity.cpp rename to map/autoware_lanelet2_map_validator/test/src/intersection/test_intersection_area_validity.cpp diff --git a/map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements_for_stop_lines.cpp b/map/autoware_lanelet2_map_validator/test/src/stop_line/test_missing_regulatory_elements_for_stop_lines.cpp similarity index 100% rename from map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements_for_stop_lines.cpp rename to map/autoware_lanelet2_map_validator/test/src/stop_line/test_missing_regulatory_elements_for_stop_lines.cpp diff --git a/map/autoware_lanelet2_map_validator/test/src/test_missing_referrers_for_traffic_lights.cpp b/map/autoware_lanelet2_map_validator/test/src/traffic_light/test_missing_referrers_for_traffic_lights.cpp similarity index 100% rename from map/autoware_lanelet2_map_validator/test/src/test_missing_referrers_for_traffic_lights.cpp rename to map/autoware_lanelet2_map_validator/test/src/traffic_light/test_missing_referrers_for_traffic_lights.cpp diff --git a/map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements_for_traffic_lights.cpp b/map/autoware_lanelet2_map_validator/test/src/traffic_light/test_missing_regulatory_elements_for_traffic_lights.cpp similarity index 100% rename from map/autoware_lanelet2_map_validator/test/src/test_missing_regulatory_elements_for_traffic_lights.cpp rename to map/autoware_lanelet2_map_validator/test/src/traffic_light/test_missing_regulatory_elements_for_traffic_lights.cpp diff --git a/map/autoware_lanelet2_map_validator/test/src/test_regulatory_elements_details_for_traffic_lights.cpp b/map/autoware_lanelet2_map_validator/test/src/traffic_light/test_regulatory_elements_details_for_traffic_lights.cpp similarity index 100% rename from map/autoware_lanelet2_map_validator/test/src/test_regulatory_elements_details_for_traffic_lights.cpp rename to map/autoware_lanelet2_map_validator/test/src/traffic_light/test_regulatory_elements_details_for_traffic_lights.cpp diff --git a/map/autoware_lanelet2_map_validator/test/src/test_traffic_light_facing.cpp b/map/autoware_lanelet2_map_validator/test/src/traffic_light/test_traffic_light_facing.cpp similarity index 100% rename from map/autoware_lanelet2_map_validator/test/src/test_traffic_light_facing.cpp rename to map/autoware_lanelet2_map_validator/test/src/traffic_light/test_traffic_light_facing.cpp From 120e1dcea8d0dd44268788fa3bf22c241b41e485 Mon Sep 17 00:00:00 2001 From: TaikiYamada4 Date: Wed, 25 Dec 2024 15:36:35 +0900 Subject: [PATCH 2/2] Rewrite CMakeLists.txt so that contributors doesn't have to write the test code name in it Signed-off-by: TaikiYamada4 --- .../CMakeLists.txt | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/map/autoware_lanelet2_map_validator/CMakeLists.txt b/map/autoware_lanelet2_map_validator/CMakeLists.txt index 80af8e75..36776605 100644 --- a/map/autoware_lanelet2_map_validator/CMakeLists.txt +++ b/map/autoware_lanelet2_map_validator/CMakeLists.txt @@ -32,42 +32,34 @@ target_link_libraries(autoware_lanelet2_map_validator ) if(BUILD_TESTING) - find_package(ament_index_cpp REQUIRED) + file(GLOB_RECURSE test_src "test/src/test_*.cpp") + ament_auto_add_library(autoware_lanelet2_map_validator_test_lib ${test_src}) - # test for json processing - ament_add_ros_isolated_gtest( - json_processing_test - test/src/test_json_processing.cpp - ) + target_include_directories(autoware_lanelet2_map_validator_test_lib PUBLIC + test/src/include + src/include) - target_link_libraries( - json_processing_test + target_link_libraries(autoware_lanelet2_map_validator_test_lib autoware_lanelet2_map_validator_lib - ament_index_cpp::ament_index_cpp ) # test for general lanelet2 map validators - function(add_validation_test VALIDATION_NAME) + function(add_validation_test TEST_FILE) + get_filename_component(TEST_NAME ${TEST_FILE} NAME_WE) + string(REPLACE "test_" "" VALIDATION_NAME ${TEST_NAME}) ament_add_ros_isolated_gtest( ${VALIDATION_NAME}_test - test/src/test_${VALIDATION_NAME}.cpp + ${TEST_FILE} ) target_link_libraries( ${VALIDATION_NAME}_test - autoware_lanelet2_map_validator_lib + autoware_lanelet2_map_validator_test_lib ) endfunction() - add_validation_test(missing_regulatory_elements_for_stop_lines) - add_validation_test(missing_regulatory_elements_for_crosswalks) - add_validation_test(missing_regulatory_elements_for_traffic_lights) - add_validation_test(regulatory_elements_details_for_crosswalks) - add_validation_test(regulatory_elements_details_for_traffic_lights) - add_validation_test(traffic_light_facing) - add_validation_test(missing_referrers_for_traffic_lights) - add_validation_test(intersection_area_validity) - add_validation_test(intersection_area_segment_type) - add_validation_test(intersection_area_dangling_reference) + foreach(TEST_FILE ${test_src}) + add_validation_test(${TEST_FILE}) + endforeach() endif() ament_auto_package(