diff --git a/cmake/tests.cmake b/cmake/tests.cmake index 57a004de0aba0..d109e044defe5 100644 --- a/cmake/tests.cmake +++ b/cmake/tests.cmake @@ -13,74 +13,3 @@ if(PYTHON_COMMAND) COMMAND ${PYTHON_COMMAND} ${CMAKE_BINARY_DIR}/test/util/rpcauth-test.py ) endif() - -if(TARGET bench_bitcoin) - add_test(NAME bench_sanity_check_high_priority - COMMAND bench_bitcoin -sanity-check -priority-level=high - ) -endif() - -if(TARGET test_bitcoin) - 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() -endif() - -if(TARGET unitester) - add_test(NAME univalue_test - COMMAND unitester - ) -endif() - -if(TARGET object) - add_test(NAME univalue_object_test - COMMAND object - ) -endif() - -if(TARGET test_bitcoin-qt) - add_test(NAME test_bitcoin-qt - COMMAND test_bitcoin-qt - ) - if(WIN32 AND VCPKG_TARGET_TRIPLET) - # On Windows, vcpkg configures Qt with `-opengl dynamic`, which makes - # the "minimal" platform plugin unusable due to internal Qt bugs. - set_tests_properties(test_bitcoin-qt PROPERTIES - ENVIRONMENT "QT_QPA_PLATFORM=windows" - ) - endif() -endif() diff --git a/src/bench/CMakeLists.txt b/src/bench/CMakeLists.txt index ea058def9fb72..89a16ec9bdc9b 100644 --- a/src/bench/CMakeLists.txt +++ b/src/bench/CMakeLists.txt @@ -73,6 +73,10 @@ if(ENABLE_WALLET) target_link_libraries(bench_bitcoin bitcoin_wallet) endif() +add_test(NAME bench_sanity_check_high_priority + COMMAND bench_bitcoin -sanity-check -priority-level=high +) + install(TARGETS bench_bitcoin RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) diff --git a/src/qt/test/CMakeLists.txt b/src/qt/test/CMakeLists.txt index 8c316108f9085..72253f8f2f257 100644 --- a/src/qt/test/CMakeLists.txt +++ b/src/qt/test/CMakeLists.txt @@ -40,6 +40,17 @@ if(NOT QT_IS_STATIC) ) endif() +add_test(NAME test_bitcoin-qt + COMMAND test_bitcoin-qt +) +if(WIN32 AND VCPKG_TARGET_TRIPLET) + # On Windows, vcpkg configures Qt with `-opengl dynamic`, which makes + # the "minimal" platform plugin unusable due to internal Qt bugs. + set_tests_properties(test_bitcoin-qt PROPERTIES + ENVIRONMENT "QT_QPA_PLATFORM=windows" + ) +endif() + install(TARGETS test_bitcoin-qt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT GUI diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index a214530a7cbf9..5444ca4dc6c7c 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -177,6 +177,44 @@ if(WITH_MULTIPROCESS) target_link_libraries(test_bitcoin bitcoin_ipc_test) endif() +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() + install(TARGETS test_bitcoin RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) diff --git a/src/univalue/CMakeLists.txt b/src/univalue/CMakeLists.txt index 22d76e895c9e8..96733fe07725d 100644 --- a/src/univalue/CMakeLists.txt +++ b/src/univalue/CMakeLists.txt @@ -25,6 +25,9 @@ if(BUILD_TESTS) core_interface univalue ) + add_test(NAME univalue_test + COMMAND unitester + ) add_executable(object test/object.cpp) target_link_libraries(object @@ -32,4 +35,7 @@ if(BUILD_TESTS) core_interface univalue ) + add_test(NAME univalue_object_test + COMMAND object + ) endif()