Skip to content

Commit 120e1dc

Browse files
committed
Rewrite CMakeLists.txt so that contributors doesn't have to write the test code name in it
Signed-off-by: TaikiYamada4 <[email protected]>
1 parent de6bb54 commit 120e1dc

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

map/autoware_lanelet2_map_validator/CMakeLists.txt

+14-22
Original file line numberDiff line numberDiff line change
@@ -32,42 +32,34 @@ target_link_libraries(autoware_lanelet2_map_validator
3232
)
3333

3434
if(BUILD_TESTING)
35-
find_package(ament_index_cpp REQUIRED)
35+
file(GLOB_RECURSE test_src "test/src/test_*.cpp")
36+
ament_auto_add_library(autoware_lanelet2_map_validator_test_lib ${test_src})
3637

37-
# test for json processing
38-
ament_add_ros_isolated_gtest(
39-
json_processing_test
40-
test/src/test_json_processing.cpp
41-
)
38+
target_include_directories(autoware_lanelet2_map_validator_test_lib PUBLIC
39+
test/src/include
40+
src/include)
4241

43-
target_link_libraries(
44-
json_processing_test
42+
target_link_libraries(autoware_lanelet2_map_validator_test_lib
4543
autoware_lanelet2_map_validator_lib
46-
ament_index_cpp::ament_index_cpp
4744
)
4845

4946
# test for general lanelet2 map validators
50-
function(add_validation_test VALIDATION_NAME)
47+
function(add_validation_test TEST_FILE)
48+
get_filename_component(TEST_NAME ${TEST_FILE} NAME_WE)
49+
string(REPLACE "test_" "" VALIDATION_NAME ${TEST_NAME})
5150
ament_add_ros_isolated_gtest(
5251
${VALIDATION_NAME}_test
53-
test/src/test_${VALIDATION_NAME}.cpp
52+
${TEST_FILE}
5453
)
5554
target_link_libraries(
5655
${VALIDATION_NAME}_test
57-
autoware_lanelet2_map_validator_lib
56+
autoware_lanelet2_map_validator_test_lib
5857
)
5958
endfunction()
6059

61-
add_validation_test(missing_regulatory_elements_for_stop_lines)
62-
add_validation_test(missing_regulatory_elements_for_crosswalks)
63-
add_validation_test(missing_regulatory_elements_for_traffic_lights)
64-
add_validation_test(regulatory_elements_details_for_crosswalks)
65-
add_validation_test(regulatory_elements_details_for_traffic_lights)
66-
add_validation_test(traffic_light_facing)
67-
add_validation_test(missing_referrers_for_traffic_lights)
68-
add_validation_test(intersection_area_validity)
69-
add_validation_test(intersection_area_segment_type)
70-
add_validation_test(intersection_area_dangling_reference)
60+
foreach(TEST_FILE ${test_src})
61+
add_validation_test(${TEST_FILE})
62+
endforeach()
7163
endif()
7264

7365
ament_auto_package(

0 commit comments

Comments
 (0)