build: cmake: add "test" target
before this change, none of the target generated by CMake-based building system runs `test.py`. but `build.ninja` generated directly by `configure.py` provides a target named `test`, which runs the `test.py` with the options passed to `configure.py`. to be more compatible with the rules generated by `configure.py`, in this change * do not include "CTest" module, as we are not using CTest for driving tests. we use the homebrew `test.py` for this purpose. more importantly, the target named "test" is provided by "CTest". so in order to add our own "test" target, we cannot use "CTest" module. * add a target named "test" to run "test.py". * add two CMake options so we can customize the behavior of "test.py", this is to be compatible with the existing behavior of `configure.py`. Refs scylladb/scylladb#2717 Signed-off-by: Kefu Chai <kefu.chai@scylladb.com> Closes scylladb/scylladb#20263
This commit is contained in:
@@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 3.27)
|
||||
|
||||
project(scylla)
|
||||
|
||||
include(CTest)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmake
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/seastar/cmake)
|
||||
|
||||
@@ -2531,6 +2531,8 @@ def configure_using_cmake(args):
|
||||
'CMAKE_EXE_LINKER_FLAGS': semicolon_separated(args.user_ldflags),
|
||||
'CMAKE_EXPORT_COMPILE_COMMANDS': 'ON',
|
||||
'Scylla_CHECK_HEADERS': 'ON',
|
||||
'Scylla_TEST_TIMEOUT': args.test_timeout,
|
||||
'Scylla_TEST_REPEAT': args.test_repeat,
|
||||
}
|
||||
if args.date_stamp:
|
||||
settings['Scylla_DATE_STAMP'] = args.date_stamp
|
||||
|
||||
@@ -83,6 +83,9 @@ function(add_scylla_test name)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
option(BUILD_TESTING
|
||||
"Build the tests" ON)
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_custom_target(tests)
|
||||
add_dependencies(tests scylla)
|
||||
@@ -92,6 +95,31 @@ if(BUILD_TESTING)
|
||||
add_subdirectory(unit)
|
||||
add_subdirectory(raft)
|
||||
add_subdirectory(resource/wasm)
|
||||
|
||||
if(CMAKE_CONFIGURATION_TYPES)
|
||||
foreach(config ${CMAKE_CONFIGURATION_TYPES})
|
||||
string(APPEND build_mode
|
||||
"$<$<CONFIG:${config}>:${scylla_build_mode_${config}}>")
|
||||
endforeach()
|
||||
else()
|
||||
set(build_mode ${scylla_build_mode_${CMAKE_BUILD_TYPE}})
|
||||
endif()
|
||||
|
||||
set(Scylla_TEST_REPEAT
|
||||
"1"
|
||||
CACHE
|
||||
STRING
|
||||
"How many times to repeat each unittest")
|
||||
set(Scylla_TEST_TIMEOUT
|
||||
"7200"
|
||||
CACHE
|
||||
STRING
|
||||
"How many seconds to allow for running all tests")
|
||||
add_custom_target(test
|
||||
COMMAND ./test.py --mode=${build_mode} --repeat=${Scylla_TEST_REPEAT} --timeout=${Scylla_TEST_TIMEOUT}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
USES_TERMINAL)
|
||||
add_dependencies(test tests)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CONFIGURATION_TYPES)
|
||||
|
||||
Reference in New Issue
Block a user