File tree Expand file tree Collapse file tree 3 files changed +56
-0
lines changed Expand file tree Collapse file tree 3 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,9 @@ else()
155155 endif ()
156156endif ()
157157
158+ find_package (Python3 3.8 REQUIRED COMPONENTS Interpreter)
159+ set (PYTHON_COMMAND ${Python3_EXECUTABLE} )
160+
158161add_subdirectory (src)
159162add_subdirectory (test )
160163
Original file line number Diff line number Diff line change @@ -288,4 +288,24 @@ endif()
288288
289289if (BUILD_TESTS)
290290 add_subdirectory (test )
291+
292+ # https://gitlab.kitware.com/cmake/community/-/wikis/doc/tutorials/EmulateMakeCheck
293+ if (TARGET bench_bitcoin)
294+ set (run_bench_bitcoin COMMAND $<TARGET_FILE:bench_bitcoin> --sanity-check)
295+ endif ()
296+
297+ set (run_util_test_runner "" )
298+ if (TARGET bitcoin-util AND TARGET bitcoin-tx)
299+ set (run_util_test_runner COMMAND echo "Running test/util/test_runner.py..." COMMAND ${CMAKE_COMMAND} -E env BITCOINUTIL=$<TARGET_FILE:bitcoin-util> BITCOINTX=$<TARGET_FILE:bitcoin-tx> ${PYTHON_COMMAND} ${CMAKE_BINARY_DIR} /test /util/test_runner.py)
300+ endif ()
301+
302+ add_custom_target (check
303+ ${run_bench_bitcoin}
304+ ${run_util_test_runner}
305+ COMMAND echo "Running test/util/rpcauth-test.py..."
306+ COMMAND ${PYTHON_COMMAND} ${CMAKE_BINARY_DIR} /test /util/rpcauth-test .py
307+ COMMAND ${CMAKE_COMMAND} -E chdir test ${CMAKE_CTEST_COMMAND} -C "$<CONFIG>"
308+ VERBATIM
309+ )
310+ add_dependencies (check test_bitcoin)
291311endif ()
Original file line number Diff line number Diff line change @@ -174,3 +174,36 @@ if(ENABLE_WALLET)
174174 target_link_libraries (test_bitcoin BerkeleyDB::BerkeleyDB)
175175 endif ()
176176endif ()
177+
178+ function (add_boost_test source_file_name)
179+ set (source_file_path "${CMAKE_CURRENT_SOURCE_DIR} /${source_file_name} " )
180+ if (NOT EXISTS ${source_file_path} )
181+ return ()
182+ endif ()
183+
184+ file (READ "${source_file_path} " source_file_content)
185+ string (REGEX
186+ MATCH "(BOOST_FIXTURE_TEST_SUITE|BOOST_AUTO_TEST_SUITE)\\ (([A-Za-z0-9_]+)"
187+ test_suite_macro "${source_file_content} "
188+ )
189+ string (REGEX
190+ REPLACE "(BOOST_FIXTURE_TEST_SUITE|BOOST_AUTO_TEST_SUITE)\\ (" ""
191+ test_suite_name "${test_suite_macro} "
192+ )
193+ if (test_suite_name)
194+ add_test (NAME "${test_suite_name} :${source_file_name} "
195+ COMMAND test_bitcoin --run_test=${test_suite_name} --catch_system_error=no
196+ )
197+ endif ()
198+ endfunction ()
199+
200+ function (add_all_test_targets)
201+ get_target_property (test_sources test_bitcoin SOURCES )
202+ foreach (test_source ${test_sources} )
203+ add_boost_test(${test_source} )
204+ endforeach ()
205+ endfunction ()
206+
207+ include (CTest)
208+ enable_testing ()
209+ add_all_test_targets()
You can’t perform that action at this time.
0 commit comments