-
-
Notifications
You must be signed in to change notification settings - Fork 782
patch st2-run-pack-tests to work with python3 #4956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,6 +66,8 @@ VIRTUALENV_ACTIVATED=false | |
| STACKSTORM_VIRTUALENV_BIN="/opt/stackstorm/st2/bin" | ||
| STACKSTORM_VIRTUALENV_PYTHON_BINARY="${STACKSTORM_VIRTUALENV_BIN}/python" | ||
|
|
||
| PYTHON_3=false | ||
|
|
||
| #################### | ||
| # Script beings here | ||
| #################### | ||
|
|
@@ -78,10 +80,11 @@ function usage() { | |
| echo " and virtualenv, if any, for subsequent test runs." >&2 | ||
| echo " -t : Run tests with timing enabled" >&2 | ||
| echo " -v : Verbose mode (log debug messages to stdout)." >&2 | ||
| echo " -3 : use python3" >&2 | ||
| echo " -x : Do not create virtualenv for test for tests, e.g. when running in existing one." >&2 | ||
| } | ||
|
|
||
| while getopts ":p:f:xjvct" o; do | ||
| while getopts ":p:f:xjvct3" o; do | ||
| case "${o}" in | ||
| p) | ||
| PACK_PATH=${OPTARG} | ||
|
|
@@ -104,6 +107,14 @@ while getopts ":p:f:xjvct" o; do | |
| t) | ||
| ENABLE_TIMING=true | ||
| ;; | ||
| 3) | ||
| PYTHON_3=true | ||
| if [ -z "$ST2_REPO_PATH" ]; then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does the python 3 flag short circuit the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the most important part. This script will look for st2 libs in \opt\stsckstorm if i dont set this. On centos7 those are python 2.7. Maybe what we do here is check the system python version vs. The version passed in this flag. If they doffer then force this env var to be set. |
||
| echo "must set ST2_REPO_PATH variable" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A clearer error message explaining what the |
||
| exit 1 | ||
| fi | ||
| ;; | ||
|
|
||
| \?) | ||
| echo "Invalid option: -$OPTARG" >&2 | ||
| usage | ||
|
|
@@ -192,8 +203,11 @@ if [ "${CREATE_VIRTUALENV}" = true ]; then | |
| if [ "${JUST_TESTS}" = false ]; then | ||
| echo "Creating virtualenv in ${VIRTUALENV_DIR}..." | ||
| mkdir -p ${VIRTUALENVS_DIR} | ||
| virtualenv --no-download --system-site-packages ${VIRTUALENV_DIR} | ||
|
|
||
| if [ "${PYTHON_3}" = false ]; then | ||
| virtualenv --no-download --system-site-packages ${VIRTUALENV_DIR} | ||
| else | ||
| virtualenv --no-download --system-site-packages ${VIRTUALENV_DIR} -p python3 | ||
| fi | ||
| # Activate the virtualenv | ||
| activate_virtualenv | ||
|
|
||
|
|
@@ -279,9 +293,12 @@ TESTS_PYTHON_PATH=() | |
| # 1. Add PYTHONPATH from StackStorm packages virtualenv (only applies when running on server when | ||
| # StackStorm is installed using packages) | ||
| if [ -f "${STACKSTORM_VIRTUALENV_PYTHON_BINARY}" ]; then | ||
| ST2_PYTHONPATH=$(${STACKSTORM_VIRTUALENV_PYTHON_BINARY} -c "import sys;print(':'.join([x for x in sys.path if x.strip()]))") | ||
| verbose_log "Adding entries from StackStorm virtualenv to PYTHONPATH: ${ST2_PYTHONPATH}" | ||
|
|
||
| if [ "${PYTHON_3}" = false ]; then | ||
| ST2_PYTHONPATH=$(${STACKSTORM_VIRTUALENV_PYTHON_BINARY} -c "import sys;print(':'.join([x for x in sys.path if x.strip()]))") | ||
| verbose_log "Adding entries from StackStorm virtualenv to PYTHONPATH: ${ST2_PYTHONPATH}" | ||
| else | ||
| verbose_log "skip Adding entries from StackStorm virtualenv to PYTHONPATH: ${ST2_PYTHONPATH}" | ||
| fi | ||
| TESTS_PYTHON_PATH+=("${ST2_PYTHONPATH}") | ||
| fi | ||
|
|
||
|
|
@@ -314,7 +331,11 @@ fi | |
| echo "Running tests..." | ||
| # Note: We run nosetests with "--exe" option so it also runs test files which are executable | ||
| # (pack install command automatically makes all the files, including test files executable) | ||
| NOSE_OPTS=(-s -v --exe --rednose --immediate) | ||
| if [ "${PYTHON_3}" = false ]; then | ||
| NOSE_OPTS=(-s -v --exe --rednose --immediate ) | ||
| else | ||
| NOSE_OPTS=(-s -v --exe ) | ||
| fi | ||
|
|
||
| # Is test coverage reporting enabled? | ||
| if [ "${ENABLE_COVERAGE}" = true ]; then | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a flag that takes an argument rather than hard coding
3(hint: use$OPTARGto get the version).3doesn't give any meaning to the purpose of the flag, usingPwould be better so there is an association withPforPython. It would be useful to be able to specify a version rather than just the major version. E.g. accept3.6,3.7,3.8to give pack developers the flexibility to test against a specific minor version.Remember to document the flag in the
Usage: $0section of the output too.