]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cmake: pass tox envs to run_tox.sh explicitly
authorKefu Chai <kchai@redhat.com>
Mon, 5 Aug 2019 15:37:52 +0000 (23:37 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 5 Aug 2019 16:06:29 +0000 (00:06 +0800)
* add two optional keyword parameters to `add_tox_test()`
* use the default `TOX_PATH` parameter instead passing it explicitly,
  as it is always `${CMAKE_CURRENT_SOURCE_DIR}`
* drop the code to guess the tox envs in `run_tox.sh`, and always pass
  them explicitly in CMake script using the `--tox-envs` argument.

Signed-off-by: Kefu Chai <kchai@redhat.com>
cmake/modules/AddCephTest.cmake
src/pybind/mgr/ansible/CMakeLists.txt
src/pybind/mgr/dashboard/CMakeLists.txt
src/pybind/mgr/insights/CMakeLists.txt
src/pybind/mgr/orchestrator_cli/CMakeLists.txt
src/python-common/CMakeLists.txt
src/script/run_tox.sh
src/tools/cephfs/CMakeLists.txt

index 0e94f3f20ced8b63e29edc331878b2e2848ba975..bb5936cf8ba61c9328e8453fc7f37a03cf32cf99 100644 (file)
@@ -53,9 +53,25 @@ function(add_ceph_unittest unittest_name)
   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}
@@ -69,9 +85,8 @@ function(add_tox_test name tox_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}
index 4ef18461942d12325a299e032f383fcdb8e5659d..476be7a98c8d890789c6b457e7f92b78cb7aa6c9 100644 (file)
@@ -1,4 +1,4 @@
 if(WITH_TESTS)
   include(AddCephTest)
-  add_tox_test(mgr-ansible ${CMAKE_CURRENT_SOURCE_DIR})
+  add_tox_test(mgr-ansible)
 endif()
index 29ea53db0920d25f5230111d83ecb6571081cb15..ad5f59e15e8a9a2e2e3f1ef2d1f75af060e37598 100644 (file)
@@ -98,5 +98,12 @@ endif(WITH_MGR_DASHBOARD_FRONTEND AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "aarch6
 
 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()
index 6137c32b704c156c8a38cb0e44a6b782238a64c7..f105a7bc9ea608720c4060f80065e48d24fb8443 100644 (file)
@@ -1,4 +1,4 @@
 if(WITH_TESTS)
   include(AddCephTest)
-  add_tox_test(mgr-insights ${CMAKE_CURRENT_SOURCE_DIR})
+  add_tox_test(mgr-insights)
 endif()
index f2e2fefc28de946f73039cc0eb7df1e754effabb..68c3346611a053378067e5ee7b441bcb6470610c 100644 (file)
@@ -1,4 +1,4 @@
 if(WITH_TESTS)
   include(AddCephTest)
-  add_tox_test(mgr-orchestrator_cli ${CMAKE_CURRENT_SOURCE_DIR})
+  add_tox_test(mgr-orchestrator_cli)
 endif()
index 08729d520a2ef006a7d2f11ea65d0432f00346a6..0b178ae9c87c2c2098d2170d7211a5c1a4f4ae21 100644 (file)
@@ -13,5 +13,5 @@ endforeach()
 
 if(WITH_TESTS)
   include(AddCephTest)
-  add_tox_test(python-common ${CMAKE_CURRENT_SOURCE_DIR})
+  add_tox_test(python-common)
 endif()
index ed4846ac585b785dbd78b45bf4a6c3895e113bd4..8c297fe70fc6aecfd21448b1581a7ada656cf24e 100755 (executable)
@@ -28,56 +28,15 @@ function get_tox_path() {
     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
@@ -90,15 +49,12 @@ function main() {
             --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;;
@@ -139,13 +95,7 @@ function main() {
     # 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 "$@"
index 41da8e3a7ac4030a3c87f4b13d4ee64dac72d6b1..d934ea414910897f6696f81f403ac2898991db5b 100644 (file)
@@ -49,6 +49,6 @@ if(WITH_CEPHFS_SHELL)
   endif()
   if(WITH_TESTS)
     include(AddCephTest)
-    add_tox_test(cephfs-shell ${CMAKE_CURRENT_SOURCE_DIR})
+    add_tox_test(cephfs-shell)
   endif()
 endif()