From d359227ec0c9c2b238272def5727eaf0c3f4ef2d Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 4 Aug 2019 14:31:03 +0800 Subject: [PATCH] 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 --- cmake/modules/AddCephTest.cmake | 11 ++++++++++- src/pybind/mgr/CMakeLists.txt | 3 --- src/pybind/mgr/ansible/CMakeLists.txt | 7 ------- src/pybind/mgr/insights/CMakeLists.txt | 7 ------- src/pybind/mgr/orchestrator_cli/CMakeLists.txt | 7 ------- 5 files changed, 10 insertions(+), 25 deletions(-) delete mode 100644 src/pybind/mgr/ansible/CMakeLists.txt delete mode 100644 src/pybind/mgr/insights/CMakeLists.txt delete mode 100644 src/pybind/mgr/orchestrator_cli/CMakeLists.txt diff --git a/cmake/modules/AddCephTest.cmake b/cmake/modules/AddCephTest.cmake index 5bc11c542bad3..c121083888061 100644 --- a/cmake/modules/AddCephTest.cmake +++ b/cmake/modules/AddCephTest.cmake @@ -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 diff --git a/src/pybind/mgr/CMakeLists.txt b/src/pybind/mgr/CMakeLists.txt index 2b5f4a7d4ad73..e7a373e0c8262 100644 --- a/src/pybind/mgr/CMakeLists.txt +++ b/src/pybind/mgr/CMakeLists.txt @@ -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") diff --git a/src/pybind/mgr/ansible/CMakeLists.txt b/src/pybind/mgr/ansible/CMakeLists.txt deleted file mode 100644 index c706aa8cbe50c..0000000000000 --- a/src/pybind/mgr/ansible/CMakeLists.txt +++ /dev/null @@ -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) diff --git a/src/pybind/mgr/insights/CMakeLists.txt b/src/pybind/mgr/insights/CMakeLists.txt deleted file mode 100644 index 00722a99581ec..0000000000000 --- a/src/pybind/mgr/insights/CMakeLists.txt +++ /dev/null @@ -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) diff --git a/src/pybind/mgr/orchestrator_cli/CMakeLists.txt b/src/pybind/mgr/orchestrator_cli/CMakeLists.txt deleted file mode 100644 index 195b79adf0c93..0000000000000 --- a/src/pybind/mgr/orchestrator_cli/CMakeLists.txt +++ /dev/null @@ -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) -- 2.39.5