cmake/modules/AddCephTest.cmake: make ${name}-venv a target

so we can prepare the venv for tox with `make tests`. and it's optional,
as run_tox.sh will check for it and setup a venv if it's not around.

Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2019-08-04 14:31:03 +08:00
parent a19761b8e8
commit d359227ec0
5 changed files with 10 additions and 25 deletions

View File

@ -53,6 +53,15 @@ endfunction()
function(add_tox_test name tox_path)
set(test_name run-tox-${name})
set(venv_path ${CEPH_BUILD_VIRTUALENV}/${name}-virtualenv)
add_custom_command(
OUTPUT ${venv_path}/bin/activate
COMMAND ${CMAKE_SOURCE_DIR}/src/tools/setup-virtualenv.sh ${venv_path}
WORKING_DIRECTORY ${tox_path}
COMMENT "preparing venv for ${name}")
add_custom_target(${name}-venv
DEPENDS ${venv_path}/bin/activate)
add_dependencies(tests ${name}-venv)
add_test(
NAME ${test_name}
COMMAND ${CMAKE_SOURCE_DIR}/src/script/run_tox.sh
@ -61,7 +70,7 @@ function(add_tox_test name tox_path)
--with-python2 ${WITH_PYTHON2}
--with-python3 ${WITH_PYTHON3}
--tox-path ${tox_path}
--venv-path ${CEPH_BUILD_VIRTUALENV}/${name})
--venv-path ${venv_path})
set_property(
TEST ${test_name}
PROPERTY ENVIRONMENT

View File

@ -1,7 +1,4 @@
add_subdirectory(dashboard)
add_subdirectory(insights)
add_subdirectory(ansible)
add_subdirectory(orchestrator_cli)
# Location needs to match default setting for mgr_module_path, currently:
# OPTION(mgr_module_path, OPT_STR, CEPH_PKGLIBDIR "/mgr")

View File

@ -1,7 +0,0 @@
set(MGR_ANSIBLE_VIRTUALENV ${CEPH_BUILD_VIRTUALENV}/mgr-ansible-virtualenv)
add_custom_target(mgr-ansible-test-venv
COMMAND ${CMAKE_SOURCE_DIR}/src/tools/setup-virtualenv.sh --python=${MGR_PYTHON_EXECUTABLE} ${MGR_ANSIBLE_VIRTUALENV}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/pybind/mgr/ansible
COMMENT "ansible tests virtualenv is being created")
add_dependencies(tests mgr-ansible-test-venv)

View File

@ -1,7 +0,0 @@
set(MGR_INSIGHTS_VIRTUALENV ${CEPH_BUILD_VIRTUALENV}/mgr-insights-virtualenv)
add_custom_target(mgr-insights-test-venv
COMMAND ${CMAKE_SOURCE_DIR}/src/tools/setup-virtualenv.sh --python=${MGR_PYTHON_EXECUTABLE} ${MGR_INSIGHTS_VIRTUALENV}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/pybind/mgr/insights
COMMENT "insights tests virtualenv is being created")
add_dependencies(tests mgr-insights-test-venv)

View File

@ -1,7 +0,0 @@
set(MGR_ORCHESTRATOR_CLI_VIRTUALENV ${CEPH_BUILD_VIRTUALENV}/mgr-orchestrator_cli-virtualenv)
add_custom_target(mgr-orchestrator_cli-test-venv
COMMAND ${CMAKE_SOURCE_DIR}/src/tools/setup-virtualenv.sh --python=${MGR_PYTHON_EXECUTABLE} ${MGR_ORCHESTRATOR_CLI_VIRTUALENV}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/pybind/mgr/orchestrator_cli
COMMENT "orchestrator_cli tests virtualenv is being created")
add_dependencies(tests mgr-orchestrator_cli-test-venv)