]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: added command to tox.ini
authoralfonsomthd <almartin@redhat.com>
Tue, 22 Jan 2019 12:26:38 +0000 (13:26 +0100)
committeralfonsomthd <almartin@redhat.com>
Tue, 22 Jan 2019 12:26:38 +0000 (13:26 +0100)
* Added 'run' command to run arbitrary commands so
  you don't have to run the whole test/lint suite.
  Use case examples:
  - Run only 1 test:
  tox -e py3-run pytest tests/test_rgw_client.py::RgwClientTest::test_ssl_verify
  - Run pycodestyle for only 1 file:
  tox -e py3-run pycodestyle tests/test_rgw_client.py

Signed-off-by: Alfonso Martínez <almartin@redhat.com>
src/pybind/mgr/dashboard/HACKING.rst
src/pybind/mgr/dashboard/run-tox.sh
src/pybind/mgr/dashboard/tox.ini

index 6446aa5bba8f8d78aaf7d3da6a44b5529ed6f754..7b9d68ee1c861e33a1c136cb44fbd3b844cb2aac 100644 (file)
@@ -394,9 +394,26 @@ Alternatively, you can use Python's native package installation method::
   $ pip install coverage
 
 To run the tests, run ``run-tox.sh`` in the dashboard directory (where
-``tox.ini`` is located).
+``tox.ini`` is located)::
 
-We also collect coverage information from the backend code. You can check the
+  ## Run Python 2+3 tests+lint commands:
+  $ ./run-tox.sh
+
+  ## Run Python 3 tests+lint commands:
+  $ WITH_PYTHON2=OFF ./run-tox.sh
+
+  ## Run Python 3 arbitrary command (e.g. 1 single test):
+  $ WITH_PYTHON2=OFF ./run-tox.sh pytest tests/test_rgw_client.py::RgwClientTest::test_ssl_verify
+
+You can also run tox instead of ``run-tox.sh``::
+
+  ## Run Python 3 tests command:
+  $ CEPH_BUILD_DIR=.tox tox -e py3-cov
+
+  ## Run Python 3 arbitrary command (e.g. 1 single test):
+  $ CEPH_BUILD_DIR=.tox tox -e py3-run pytest tests/test_rgw_client.py::RgwClientTest::test_ssl_verify
+
+We also collect coverage information from the backend code when you run tests. You can check the
 coverage information provided by the tox output, or by running the following
 command after tox has finished successfully::
 
@@ -405,11 +422,6 @@ command after tox has finished successfully::
 This command will create a directory ``htmlcov`` with an HTML representation of
 the code coverage of the backend.
 
-You can also run a single step of the tox script (aka tox environment), for
-instance if you only want to run the linting tools, do::
-
-  $ tox -e lint
-
 API tests based on Teuthology
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
index b43e273679f9fa7585d0aa2d11cc6dc95249c124..c57f93a4802f3bdb2379ad415012ee6125da48f7 100755 (executable)
@@ -20,10 +20,18 @@ export CEPH_BUILD_DIR=$CEPH_BUILD_DIR
 source ${MGR_DASHBOARD_VIRTUALENV}/bin/activate
 
 if [ "$WITH_PYTHON2" = "ON" ]; then
-  ENV_LIST+="py27-cov,py27-lint,"
+  if [[ -n "$@" ]]; then
+    ENV_LIST+="py27-run,"
+  else
+    ENV_LIST+="py27-cov,py27-lint,"
+  fi
 fi
 if [ "$WITH_PYTHON3" = "ON" ]; then
-  ENV_LIST+="py3-cov,py3-lint"
+  if [[ -n "$@" ]]; then
+    ENV_LIST+="py3-run"
+  else
+    ENV_LIST+="py3-cov,py3-lint"
+  fi
 fi
 
-tox -c ${TOX_PATH} -e $ENV_LIST
+tox -c ${TOX_PATH} -e "$ENV_LIST" "$@"
index 89d3c3269cf05879ba4952d23f2b6f4a5811d937..e0876f4eb2f890ee758b889f31f38f8b29a373fd 100644 (file)
@@ -1,5 +1,5 @@
 [tox]
-envlist = {py27,py3}-cov,{py27,py3}-lint
+envlist = py27-{cov,lint,run},py3-{cov,lint,run}
 skipsdist = true
 toxworkdir = {env:CEPH_BUILD_DIR}/dashboard
 minversion = 2.8.1
@@ -27,3 +27,4 @@ commands=
     cov: coverage xml
     lint: pylint --rcfile=.pylintrc --jobs=5 . module.py tools.py controllers tests services exceptions.py
     lint: pycodestyle --max-line-length=100 --exclude=.tox,venv,frontend,.vscode --ignore=E402,E121,E123,E126,E226,E24,E704,W503,E741 .
+    run: {posargs}