Lint st2-run-pack-tests a bit
@@ -118,7 +118,7 @@ while getopts ":p:f:xjvct" o; do
done
function verbose_log() {
- if [ ${VERBOSE} = true ]; then
+ if [ "${VERBOSE}" = true ]; then
echo $@
fi
}
@@ -132,19 +132,19 @@ function activate_virtualenv() {
fi
}
-if [ ! ${PACK_PATH} ]; then
+if [ -z "${PACK_PATH}" ]; then
# Missing required argument
usage
exit 2
fi
PACK_PATH=$(readlink -f ${PACK_PATH})
-if [ ! ${PACK_PATH} ]; then
+if [ -z "${PACK_PATH}" ]; then
echo "Usage: $0 -p <pack path> [-x]"
exit 2
fi
-if [ ! -d ${PACK_PATH} ]; then
+if [ ! -d "${PACK_PATH}" ]; then
echo "Invalid pack path: ${PACK_PATH}"
exit 3
fi
@@ -162,7 +162,7 @@ ETC_PATH="${PACK_PATH}/etc/"
# Bail early if no tests are found, this way we don't need to wait for
# environment set up.
-if [ ! -d ${PACK_TESTS_PATH} ]; then
+if [ ! -d "${PACK_TESTS_PATH}" ]; then
echo "Running tests for pack: ${PACK_NAME}"
echo "No tests found."
exit 0
@@ -214,7 +214,7 @@ fi
# Note: If we are running outside of st2, we need to add all the st2 components
# to PYTHONPATH
-if [ ${ST2_REPO_PATH} ]; then
+if [ -n "${ST2_REPO_PATH}" ]; then
ST2_REPO_PATH=${ST2_REPO_PATH:-/tmp/st2}
ST2_COMPONENTS=$(find ${ST2_REPO_PATH}/* -maxdepth 0 -name "st2*" -type d)
ST2_RUNNERS=$(find ${ST2_REPO_PATH}/contrib/runners/* -maxdepth 0 -type d 2> /dev/null)
@@ -289,12 +289,12 @@ fi
TESTS_PYTHON_PATH+=("${PACK_PYTHONPATH}")
# 3. Add any exist PYTHONPATH at the end
-if [ ! -z "${PYTHONPATH}" ]; then
+if [ -n "${PYTHONPATH}" ]; then
TESTS_PYTHON_PATH+=("${PYTHONPATH}")
fi
# 4. Add in tests path if test file is provided
-if [ ! -z "${TEST_LOCATION}" ]; then
+if [ -n "${TEST_LOCATION}" ]; then
TESTS_PYTHON_PATH+=("${PACK_TESTS_PATH}")
fi
@@ -307,7 +307,7 @@ verbose_log "PATH=${PATH}"
verbose_log "Virtualenv activated=${VIRTUALENV_ACTIVATED}"
verbose_log "Installed Python dependencies:"
-if [ ${VERBOSE} = true ]; then
+if [ "${VERBOSE}" = true ]; then
pip list --format columns
fi
@@ -362,7 +362,7 @@ TESTS_EXIT_CODE=$?
popd > /dev/null # ${PACK_PATH}
# Clean up and unset the variables
-if [ ${VIRTUALENV_ACTIVATED} = true ]; then
+if [ "${VIRTUALENV_ACTIVATED}" = true ]; then
verbose_log "Deactivating virtualenv ${VIRTUALENVS_DIR}"
deactivate
fi
