target_link_libraries(${unittest_name} ${UNITTEST_LIBS})
endfunction()
-function(add_tox_test name tox_path)
+function(add_tox_test name)
set(test_name run-tox-${name})
set(venv_path ${CEPH_BUILD_VIRTUALENV}/${name}-virtualenv)
+ cmake_parse_arguments(TOXTEST "" "TOX_PATH" "TOX_ENVS" ${ARGN})
+ if(DEFINED TOXTEST_TOX_PATH)
+ set(tox_path ${TOXTEST_TOX_PATH})
+ else()
+ set(tox_path ${CMAKE_CURRENT_SOURCE_DIR})
+ endif()
+ if(WITH_PYTHON2)
+ list(APPEND tox_envs py27)
+ endif()
+ if(WITH_PYTHON3)
+ list(APPEND tox_envs py3)
+ endif()
+ if(DEFINED TOXTEST_TOX_ENVS)
+ set(tox_envs ${TOXTEST_TOX_ENVS})
+ endif()
+ string(REPLACE ";" "," tox_envs "${tox_envs}")
add_custom_command(
OUTPUT ${venv_path}/bin/activate
COMMAND ${CMAKE_SOURCE_DIR}/src/tools/setup-virtualenv.sh ${venv_path}
COMMAND ${CMAKE_SOURCE_DIR}/src/script/run_tox.sh
--source-dir ${CMAKE_SOURCE_DIR}
--build-dir ${CMAKE_BINARY_DIR}
- --with-python2 ${WITH_PYTHON2}
- --with-python3 ${WITH_PYTHON3}
--tox-path ${tox_path}
+ --tox-envs ${tox_envs}
--venv-path ${venv_path})
set_property(
TEST ${test_name}
if(WITH_TESTS)
include(AddCephTest)
- add_tox_test(mgr-ansible ${CMAKE_CURRENT_SOURCE_DIR})
+ add_tox_test(mgr-ansible)
endif()
if(WITH_TESTS)
include(AddCephTest)
- add_tox_test(mgr-dashboard ${CMAKE_CURRENT_SOURCE_DIR})
+ if(WITH_PYTHON2)
+ list(APPEND dashboard_tox_envs py27-cov py27-lint py27-check)
+ endif()
+ if(WITH_PYTHON3)
+ list(APPEND dashboard_tox_envs py3-cov py3-lint py3-check)
+ endif()
+ add_tox_test(mgr-dashboard
+ TOX_ENVS ${dashboard_tox_envs})
endif()
if(WITH_TESTS)
include(AddCephTest)
- add_tox_test(mgr-insights ${CMAKE_CURRENT_SOURCE_DIR})
+ add_tox_test(mgr-insights)
endif()
if(WITH_TESTS)
include(AddCephTest)
- add_tox_test(mgr-orchestrator_cli ${CMAKE_CURRENT_SOURCE_DIR})
+ add_tox_test(mgr-orchestrator_cli)
endif()
if(WITH_TESTS)
include(AddCephTest)
- add_tox_test(python-common ${CMAKE_CURRENT_SOURCE_DIR})
+ add_tox_test(python-common)
endif()
fi
}
-function get_env_list_for_dashboard() {
- local with_python2=$1
- shift
- local with_python3=$1
- shift
- local env_list
- if $with_python2; then
- if [ $# -gt 0 ]; then
- env_list+="py27-run,"
- else
- env_list+="py27-cov,py27-lint,py27-check,"
- fi
- fi
- if $with_python3; then
- if [ $# -gt 0 ]; then
- env_list+="py3-run,"
- else
- env_list+="py3-cov,py3-lint,py3-check,"
- fi
- fi
- # use bash string manipulation to strip off any trailing comma
- echo "${env_list%,}"
-}
-
-function get_env_list() {
- local with_python2=$1
- shift
- local with_python3=$1
- shift
- local env_list
- if $with_python2; then
- env_list+="py27,"
- fi
- if $with_python3; then
- env_list+="py3,"
- fi
- # use bash string manipulation to strip off any trailing comma
- echo "${env_list%,}"
-}
-
function main() {
local tox_path
local script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
local build_dir=$script_dir/../../build
local source_dir=$(get_cmake_variable $build_dir ceph_SOURCE_DIR)
- local with_python2=$(get_cmake_variable $build_dir WITH_PYTHON2)
- local with_python3=$(get_cmake_variable $build_dir WITH_PYTHON3)
- local parsed
+ local tox_envs
+ local options
- options=$(${GETOPT} --name "$0" --options '' --longoptions "source-dir:,build-dir:,with-python2:,with-python3:,tox-path:,venv-path:" -- "$@")
+ options=$(${GETOPT} --name "$0" --options '' --longoptions "source-dir:,build-dir:,tox-path:,tox-envs:,venv-path:" -- "$@")
if [ $? -ne 0 ]; then
exit 2
fi
--build-dir)
build_dir=$2
shift 2;;
- --with-python2)
- with_python2=$2
- shift 2;;
- --with-python3)
- with_python3=$2
- shift 2;;
--tox-path)
tox_path=$2
shift 2;;
+ --tox-envs)
+ tox_envs=$2
+ shift 2;;
--venv-path)
venv_path=$2
shift 2;;
# tox.ini will take care of this.
export CEPH_BUILD_DIR=$build_dir
- local env_list
- if [ $test_name = "dashboard" ]; then
- env_list=$(get_env_list_for_dashboard $with_python2 $with_python3 "$@")
- else
- env_list=$(get_env_list $with_python2 $with_python3)
- fi
- tox -c $tox_path/tox.ini -e "$env_list" "$@"
+ tox -c $tox_path/tox.ini -e "$tox_envs" "$@"
}
main "$@"
endif()
if(WITH_TESTS)
include(AddCephTest)
- add_tox_test(cephfs-shell ${CMAKE_CURRENT_SOURCE_DIR})
+ add_tox_test(cephfs-shell)
endif()
endif()