# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# Run yardstick's flake8, unit, coverage, functional test
+# Run yardstick's unit, coverage, functional test
getopts ":f" FILE_OPTION
+opts=$@ # get other args
-run_flake8() {
- echo "Running flake8 ... "
- logfile=test_results.log
- if [ $FILE_OPTION == "f" ]; then
- flake8 yardstick > $logfile
- else
- flake8 yardstick
- fi
+# don't write .pyc files this can cause odd unittest results
+export PYTHONDONTWRITEBYTECODE=1
- if [ $? -ne 0 ]; then
- echo "FAILED"
- if [ $FILE_OPTION == "f" ]; then
- echo "Results in $logfile"
- fi
- exit 1
- else
- echo "OK"
- fi
-}
+PY_VER="py$( python --version | sed 's/[^[:digit:]]//g' | cut -c-2 )"
+export PY_VER
+
+COVER_DIR_NAME="./tests/ci/"
+export COVER_DIR_NAME
run_tests() {
+ echo "Get external libs needed for unit test"
+
echo "Running unittest ... "
if [ $FILE_OPTION == "f" ]; then
python -m unittest discover -v -s tests/unit > $logfile 2>&1
}
run_coverage() {
- source tests/ci/cover.sh
+ source $COVER_DIR_NAME/cover.sh
run_coverage_test
}
fi
}
-export PYTHONPATH='yardstick/vTC/apexlake'
+if [[ $opts =~ "--unit" ]]; then
+ run_tests
+fi
+
+if [[ $opts =~ "--coverage" ]]; then
+ run_coverage
+fi
+
+if [[ $opts =~ "--functional" ]]; then
+ run_functional_test
+fi
-run_flake8
-run_tests
-run_coverage
-run_functional_test
+if [[ -z $opts ]]; then
+ echo "No tests to run!!"
+ echo "Usage: run_tests.sh [--unit] [--coverage] [--functional]"
+ exit 1
+fi