Add add_qt_manual_test()
This patch adds add_qt_manual_test() which is a simple wrapper around add_qt_executable() which does not build under ${CMAKE_BUILD_DIR}/bin or install the targets. This could potentially be used later to tag manual tests. Change-Id: Ic4e0a1d133009f5a858b9394347a0996cf42683f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
f33069be24
commit
681e8b4ead
@ -2390,6 +2390,40 @@ function(add_qt_benchmark target)
|
|||||||
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
# Simple wrapper around add_qt_executable for manual tests which insure that
|
||||||
|
# the binary is built under ${CMAKE_CURRENT_BINARY_DIR} and never installed.
|
||||||
|
# See add_qt_executable() for more details.
|
||||||
|
function(add_qt_manual_test target)
|
||||||
|
|
||||||
|
qt_parse_all_arguments(arg "add_qt_benchmark"
|
||||||
|
"${__add_qt_executable_optional_args}"
|
||||||
|
"${__add_qt_executable_single_args}"
|
||||||
|
"${__add_qt_executable_multi_args}"
|
||||||
|
${ARGN}
|
||||||
|
)
|
||||||
|
|
||||||
|
qt_remove_args(exec_args
|
||||||
|
ARGS_TO_REMOVE
|
||||||
|
${target}
|
||||||
|
OUTPUT_DIRECTORY
|
||||||
|
INSTALL_DIRECTORY
|
||||||
|
ALL_ARGS
|
||||||
|
"${__add_qt_executable_optional_args}"
|
||||||
|
"${__add_qt_executable_single_args}"
|
||||||
|
"${__add_qt_executable_multi_args}"
|
||||||
|
ARGS
|
||||||
|
${ARGV}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_qt_executable(${target}
|
||||||
|
NO_INSTALL # we don't install benchmarks
|
||||||
|
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" # avoid polluting bin directory
|
||||||
|
${exec_args}
|
||||||
|
)
|
||||||
|
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
# This function creates a CMake test target with the specified name for use with CTest.
|
# This function creates a CMake test target with the specified name for use with CTest.
|
||||||
function(add_qt_test name)
|
function(add_qt_test name)
|
||||||
qt_parse_all_arguments(arg "add_qt_test"
|
qt_parse_all_arguments(arg "add_qt_test"
|
||||||
|
@ -246,9 +246,18 @@ def is_benchmark_project(project_file_path: str = "") -> bool:
|
|||||||
|
|
||||||
project_relative_path = os.path.relpath(project_file_path, qmake_conf_dir_path)
|
project_relative_path = os.path.relpath(project_file_path, qmake_conf_dir_path)
|
||||||
# If the project file is found in a subdir called 'tests/benchmarks'
|
# If the project file is found in a subdir called 'tests/benchmarks'
|
||||||
# relative to the repo source dir, then it must be benchmark
|
# relative to the repo source dir, then it must be a benchmark
|
||||||
return project_relative_path.startswith("tests/benchmarks")
|
return project_relative_path.startswith("tests/benchmarks")
|
||||||
|
|
||||||
|
def is_manual_test(project_file_path: str = "") -> bool:
|
||||||
|
qmake_conf_path = find_qmake_conf(project_file_path)
|
||||||
|
qmake_conf_dir_path = os.path.dirname(qmake_conf_path)
|
||||||
|
|
||||||
|
project_relative_path = os.path.relpath(project_file_path, qmake_conf_dir_path)
|
||||||
|
# If the project file is found in a subdir called 'tests/manual'
|
||||||
|
# relative to the repo source dir, then it must be a manual test
|
||||||
|
return project_relative_path.startswith("tests/manual")
|
||||||
|
|
||||||
|
|
||||||
@lru_cache(maxsize=None)
|
@lru_cache(maxsize=None)
|
||||||
def find_qmake_conf(project_file_path: str = "") -> str:
|
def find_qmake_conf(project_file_path: str = "") -> str:
|
||||||
@ -2808,6 +2817,7 @@ def write_binary(cm_fh: IO[str], scope: Scope, gui: bool = False, *, indent: int
|
|||||||
assert binary_name
|
assert binary_name
|
||||||
|
|
||||||
is_benchmark = is_benchmark_project(scope.file_absolute_path)
|
is_benchmark = is_benchmark_project(scope.file_absolute_path)
|
||||||
|
is_manual_test = is_manual_test(scope.file_absolute_path)
|
||||||
|
|
||||||
is_qt_test_helper = "qt_test_helper" in scope.get("_LOADED")
|
is_qt_test_helper = "qt_test_helper" in scope.get("_LOADED")
|
||||||
|
|
||||||
@ -2821,6 +2831,8 @@ def write_binary(cm_fh: IO[str], scope: Scope, gui: bool = False, *, indent: int
|
|||||||
|
|
||||||
if is_benchmark:
|
if is_benchmark:
|
||||||
cmake_function_call = "add_qt_benchmark"
|
cmake_function_call = "add_qt_benchmark"
|
||||||
|
elif is_manual_test:
|
||||||
|
cmake_function_call = "add_qt_manual_test"
|
||||||
else:
|
else:
|
||||||
extra_keys = ["target.path", "INSTALLS"]
|
extra_keys = ["target.path", "INSTALLS"]
|
||||||
target_path = scope.get_string("target.path")
|
target_path = scope.get_string("target.path")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user