mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-31 00:05:13 +02:00
cmake: Create test suite for ctest
This commit is contained in:
@@ -153,3 +153,41 @@ target_link_libraries(test_bitcoin
|
||||
Boost::headers
|
||||
$<TARGET_NAME_IF_EXISTS:libevent::libevent>
|
||||
)
|
||||
|
||||
function(add_boost_test source_file)
|
||||
if(NOT EXISTS ${source_file})
|
||||
return()
|
||||
endif()
|
||||
|
||||
file(READ "${source_file}" source_file_content)
|
||||
string(REGEX
|
||||
MATCH "(BOOST_FIXTURE_TEST_SUITE|BOOST_AUTO_TEST_SUITE)\\(([A-Za-z0-9_]+)"
|
||||
test_suite_macro "${source_file_content}"
|
||||
)
|
||||
string(REGEX
|
||||
REPLACE "(BOOST_FIXTURE_TEST_SUITE|BOOST_AUTO_TEST_SUITE)\\(" ""
|
||||
test_suite_name "${test_suite_macro}"
|
||||
)
|
||||
if(test_suite_name)
|
||||
add_test(NAME ${test_suite_name}
|
||||
COMMAND test_bitcoin --run_test=${test_suite_name} --catch_system_error=no
|
||||
)
|
||||
set_property(TEST ${test_suite_name} PROPERTY
|
||||
SKIP_REGULAR_EXPRESSION "no test cases matching filter" "Skipping"
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(add_all_test_targets)
|
||||
get_target_property(test_source_dir test_bitcoin SOURCE_DIR)
|
||||
get_target_property(test_sources test_bitcoin SOURCES)
|
||||
foreach(test_source ${test_sources})
|
||||
cmake_path(IS_RELATIVE test_source result)
|
||||
if(result)
|
||||
cmake_path(APPEND test_source_dir ${test_source} OUTPUT_VARIABLE test_source)
|
||||
endif()
|
||||
add_boost_test(${test_source})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
add_all_test_targets()
|
||||
|
||||
Reference in New Issue
Block a user