Add *_check
build targets for auto cmake tests
Similar `*_check` targets are created in `qt_internal_add_test`. This change extends that implementation to auto cmake tests. Note: These generated targets do not have additional dependencies, on the build targets, unlike those generated by `qt_internal_add_test`. You would need to (re-)run the build first separately and then run the `*_check` target. Fixes: QTBUG-98640 Pick-to: 6.8 6.9 Change-Id: I387f09570b6a4a345756133870c2eb9ef1cf3cf8 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
4d9f99c4ea
commit
8f2f4ad468
@ -121,3 +121,35 @@ endfunction()
|
||||
function(_qt_internal_test_batch_target_name out)
|
||||
set(${out} "test_batch" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Create a *_check target of the ctest execution for alternative execution
|
||||
# Arguments:
|
||||
# : CTEST_TEST_NAME: (default: ${testname})
|
||||
# name of the ctest test used
|
||||
function(_qt_internal_make_check_target testname)
|
||||
set(options "")
|
||||
set(singleOpts CTEST_TEST_NAME)
|
||||
set(multiOpts "")
|
||||
|
||||
cmake_parse_arguments(PARSE_ARGV 0 arg
|
||||
"${options}" "${singleOpts}" "${multiOpts}"
|
||||
)
|
||||
if(NOT arg_CTEST_TEST_NAME)
|
||||
set(arg_CTEST_TEST_NAME ${testname})
|
||||
endif()
|
||||
|
||||
set(test_config_options "")
|
||||
get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
|
||||
if(is_multi_config)
|
||||
set(test_config_options -C $<CONFIG>)
|
||||
endif()
|
||||
# Note: By default the working directory here is CMAKE_CURRENT_BINARY_DIR, which will
|
||||
# work as long as this is called anywhere up or down the path where the equivalent
|
||||
# `add_test` is called (not down a different branch path).
|
||||
add_custom_target(${testname}_check
|
||||
VERBATIM
|
||||
COMMENT "Running ctest -V -R \"^${arg_CTEST_TEST_NAME}$\" ${test_config_options}"
|
||||
COMMAND
|
||||
"${CMAKE_CTEST_COMMAND}" -V -R "^${arg_CTEST_TEST_NAME}$" ${test_config_options}
|
||||
)
|
||||
endfunction()
|
||||
|
@ -794,18 +794,10 @@ function(qt_internal_add_test name)
|
||||
)
|
||||
endif()
|
||||
|
||||
# Add a ${target}/check makefile target, to more easily test one test.
|
||||
|
||||
set(test_config_options "")
|
||||
get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
|
||||
if(is_multi_config)
|
||||
set(test_config_options -C $<CONFIG>)
|
||||
endif()
|
||||
add_custom_target("${testname}_check"
|
||||
VERBATIM
|
||||
COMMENT "Running ${CMAKE_CTEST_COMMAND} -V -R \"^${name}$\" ${test_config_options}"
|
||||
COMMAND "${CMAKE_CTEST_COMMAND}" -V -R "^${name}$" ${test_config_options}
|
||||
)
|
||||
# Add a ${target}_check makefile target, to more easily test one test.
|
||||
# TODO: Note in batch mode testname tests would execute all batched tests defined in name
|
||||
_qt_internal_make_check_target(${testname} CTEST_TEST_NAME ${name})
|
||||
# Add appropriate dependencies to the targets as needed
|
||||
if(TARGET "${name}")
|
||||
add_dependencies("${testname}_check" "${name}")
|
||||
if(ANDROID)
|
||||
|
@ -482,6 +482,7 @@ macro(_qt_internal_test_expect_pass _dir)
|
||||
)
|
||||
endif()
|
||||
set_tests_properties(${testname} PROPERTIES ENVIRONMENT "ASAN_OPTIONS=detect_leaks=0")
|
||||
_qt_internal_make_check_target(${testname})
|
||||
|
||||
if(_ARGS_BINARY)
|
||||
set(run_env_args "")
|
||||
@ -703,6 +704,7 @@ list(APPEND CMAKE_PREFIX_PATH \"${__expect_fail_prefixes}\")
|
||||
add_test(${testname} "${CMAKE_COMMAND}" "-P" "${wrapper_file}")
|
||||
set_tests_properties(${testname} PROPERTIES
|
||||
SKIP_REGULAR_EXPRESSION "${_qt_internal_skip_build_test_regex}")
|
||||
_qt_internal_make_check_target(${testname})
|
||||
|
||||
unset(__expect_fail_prefixes)
|
||||
endmacro()
|
||||
@ -826,4 +828,5 @@ function(_qt_internal_test_module_includes)
|
||||
add_test(module_includes "${CMAKE_COMMAND}" "-P" "${wrapper_file}")
|
||||
set_tests_properties(module_includes PROPERTIES
|
||||
SKIP_REGULAR_EXPRESSION "${_qt_internal_skip_build_test_regex}")
|
||||
_qt_internal_make_check_target(module_includes)
|
||||
endfunction()
|
||||
|
Loading…
x
Reference in New Issue
Block a user