You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by dp...@apache.org on 2020/07/16 12:04:12 UTC
[incubator-superset] branch master updated: tests: update test run
doc and add some improvements (#10339)
This is an automated email from the ASF dual-hosted git repository.
dpgaspar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new e4c9c73 tests: update test run doc and add some improvements (#10339)
e4c9c73 is described below
commit e4c9c7364bbcecdbbe008ce5e6ce9065c28b3dfc
Author: Daniel Vaz Gaspar <da...@gmail.com>
AuthorDate: Thu Jul 16 13:03:49 2020 +0100
tests: update test run doc and add some improvements (#10339)
* fix: update tests/run.sh README to pytest and some improvements
* update docs
* nit
* fix doc
---
scripts/tests/README.md | 24 ++++++++++++++++++------
scripts/tests/run.sh | 33 +++++++++++++++------------------
2 files changed, 33 insertions(+), 24 deletions(-)
diff --git a/scripts/tests/README.md b/scripts/tests/README.md
index 430a155..18f3805 100644
--- a/scripts/tests/README.md
+++ b/scripts/tests/README.md
@@ -24,38 +24,50 @@ so prior to using this script make sure to launch the dev containers.
You can use a different DB backend by defining `SUPERSET__SQLALCHEMY_DATABASE_URI` env var.
+This script will not install any dependencies for you, so you must be on an already set virtualenv
+
## Use:
+To show all supported switches:
+```$bash
+scripts/tests/run.sh --help
+```
+
From the superset repo root directory:
+- Example run all tests:
+```$bash
+scripts/tests/run.sh
+```
+
- Example run a single test module:
```$bash
-scripts/tests/run.sh tests.charts.api_tests
+scripts/tests/run.sh --module tests/charts/api_tests.py
```
- Example run a single test:
```$bash
-scripts/tests/run.sh tests.charts.api_tests:ChartApiTests.test_get_charts
+scripts/tests/run.sh --module tests/charts/api_tests.py::TestChartApi::test_get_charts
```
- Example run a single test, without any init procedures. Init procedures include:
resetting test database, db upgrade, superset init, loading example data. If your tests
are idempotent, after the first run, subsequent runs are really fast
```$bash
-scripts/tests/run.sh tests.charts.api_tests:ChartApiTests.test_get_charts --no-init
+scripts/tests/run.sh --module tests/charts/api_tests.py::TestChartApi::test_get_charts --no-init
```
- Example for not recreating the test DB (will still run all the tests init procedures)
```$bash
-scripts/tests/run.sh tests.charts.api_tests:ChartApiTests.test_get_charts --no-reset-db
+scripts/tests/run.sh --module tests/charts/api_tests.py::TestChartApi::test_get_charts --no-reset-db
```
- Example for not running tests just initialize the test DB (drop/create, upgrade and load examples)
```$bash
-scripts/tests/run.sh . --no-tests
+scripts/tests/run.sh --no-tests
```
- Example for just resetting the tests DB
```$bash
-scripts/tests/run.sh . --reset-db
+scripts/tests/run.sh --reset-db --no-tests
```
diff --git a/scripts/tests/run.sh b/scripts/tests/run.sh
index aeffeb0..98206f4 100755
--- a/scripts/tests/run.sh
+++ b/scripts/tests/run.sh
@@ -59,19 +59,6 @@ function test_init() {
pytest -s tests/load_examples_test.py
}
-
-if [[ "$#" -eq "0" ]]
-then
- echo "No argument suplied"
- echo ------------------------
- echo use:
- echo "run.sh <test module name> [options]"
- echo "[options]:"
- echo "--no-init: Dont restart docker and no db migrations, superset init and test data"
- echo "--no-reset-db: Recreates test database (DROP, CREATE)"
- exit 1
-fi
-
#
# Init global vars
#
@@ -83,14 +70,20 @@ export SUPERSET_CONFIG=${SUPERSET_CONFIG:-tests.superset_test_config}
RUN_INIT=1
RUN_RESET_DB=1
RUN_TESTS=1
-TEST_MODULE="${1}"
-
-# Shift to pass the first cmd parameter for the test module
-shift 1
+TEST_MODULE="tests"
PARAMS=""
while (( "$#" )); do
case "$1" in
+ --help)
+ echo Switches:
+ echo --no-init : Will not, reset the test DB, superset init and load examples
+ echo --no-reset-db: Will not reset the test DB
+ echo --no-tests: Will not run any test, by default reset the DB, superset init and load_examples
+ echo --reset-db: Just resets the test DB, will not run any test
+ echo --module: Run a specific test module: --module tests/charts/api_tests.py for example
+ exit 0
+ ;;
--no-init)
RUN_INIT=0
RUN_RESET_DB=0
@@ -109,6 +102,10 @@ while (( "$#" )); do
RUN_INIT=0
shift 1
;;
+ --module)
+ TEST_MODULE=$2
+ shift 2
+ ;;
--) # end argument parsing
shift
break
@@ -145,5 +142,5 @@ fi
if [ $RUN_TESTS -eq 1 ]
then
- pytest -s --ignore=load_examples_test "${TEST_MODULE}"
+ pytest -x -s --ignore=load_examples_test "${TEST_MODULE}"
fi