build: group unit tests for better build times with LTO

This commit is contained in:
Marcus Holland-Moritz 2025-04-19 23:42:29 +02:00
parent 3cf45955d2
commit 02b12418cc

View File

@ -484,46 +484,63 @@ endif()
if(WITH_TESTS) if(WITH_TESTS)
if(WITH_LIBDWARFS) if(WITH_LIBDWARFS)
list(APPEND DWARFS_TESTS add_executable(dwarfs_unit_tests
badfs_test test/badfs_test.cpp
block_merger_test test/block_merger_test.cpp
block_range_test test/block_range_test.cpp
checksum_test test/checksum_test.cpp
chmod_transformer_test test/chmod_transformer_test.cpp
compat_test test/entry_test.cpp
dwarfs_test test/error_test.cpp
entry_test test/file_access_test.cpp
error_test test/file_utils_test.cpp
file_access_test test/filesystem_test.cpp
filesystem_test test/filesystem_writer_test.cpp
filesystem_writer_test test/fragment_category_test.cpp
fits_categorizer_test test/glob_matcher_test.cpp
fragment_category_test test/global_metadata_test.cpp
glob_matcher_test test/integral_value_parser_test.cpp
global_metadata_test test/lazy_value_test.cpp
incompressible_categorizer_test test/metadata_requirements_test.cpp
integral_value_parser_test test/nilsimsa_test.cpp
lazy_value_test test/options_test.cpp
metadata_requirements_test test/packed_int_vector_test.cpp
nilsimsa_test test/packed_ptr_test.cpp
options_test test/pcm_sample_transformer_test.cpp
packed_int_vector_test test/sorted_array_map_test.cpp
packed_ptr_test test/speedometer_test.cpp
pcm_sample_transformer_test test/terminal_test.cpp
pcmaudio_categorizer_test test/unicode_test.cpp
sorted_array_map_test test/utils_test.cpp
speedometer_test test/worker_group_test.cpp
terminal_test
unicode_test
utils_test
file_utils_test
worker_group_test
) )
if(FLAC_FOUND) add_executable(dwarfs_categorizer_tests
list(APPEND DWARFS_TESTS test/fits_categorizer_test.cpp
flac_compressor_test test/incompressible_categorizer_test.cpp
) test/pcmaudio_categorizer_test.cpp
)
add_executable(dwarfs_expensive_tests
test/compat_test.cpp
test/dwarfs_test.cpp
)
list(APPEND DWARFS_TESTS
dwarfs_categorizer_tests
dwarfs_expensive_tests
dwarfs_unit_tests
)
if(FLAC_FOUND OR ENABLE_RICEPP)
add_executable(dwarfs_compressor_tests)
list(APPEND DWARFS_TESTS dwarfs_compressor_tests)
if(FLAC_FOUND)
target_sources(dwarfs_compressor_tests PRIVATE test/flac_compressor_test.cpp)
endif()
if(ENABLE_RICEPP)
target_sources(dwarfs_compressor_tests PRIVATE test/ricepp_compressor_test.cpp)
endif()
endif() endif()
endif() endif()
@ -551,12 +568,11 @@ if(WITH_TESTS)
list(APPEND DWARFS_TESTS manpage_test) list(APPEND DWARFS_TESTS manpage_test)
endif() endif()
if(WITH_LIBDWARFS AND ENABLE_RICEPP)
list(APPEND DWARFS_TESTS ricepp_compressor_test)
endif()
foreach (test ${DWARFS_TESTS}) foreach (test ${DWARFS_TESTS})
add_executable(${test} test/${test}.cpp) if(NOT TARGET ${test})
add_executable(${test} test/${test}.cpp)
endif()
target_link_libraries( target_link_libraries(
${test} PRIVATE dwarfs_test_helpers gmock gtest gtest_main ${test} PRIVATE dwarfs_test_helpers gmock gtest gtest_main
) )
@ -608,9 +624,7 @@ if(WITH_TESTS)
target_link_libraries(block_cache_test PRIVATE mkdwarfs_main) target_link_libraries(block_cache_test PRIVATE mkdwarfs_main)
endif() endif()
foreach(tgt fits_categorizer_test foreach(tgt dwarfs_categorizer_tests
incompressible_categorizer_test
pcmaudio_categorizer_test
tool_main_test) tool_main_test)
if(TARGET ${tgt}) if(TARGET ${tgt})
target_link_libraries(${tgt} PRIVATE dwarfs_writer) target_link_libraries(${tgt} PRIVATE dwarfs_writer)