3 ##############################################################################
4 # Copyright (c) 2015 Ericsson AB and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
12 # Run yardstick's flake8, unit, coverage, functional test
14 getopts ":f" FILE_OPTION
16 # don't write .pyc files this can cause odd unittest results
17 export PYTHONDONTWRITEBYTECODE=1
19 PY_VER="py$( python --version | sed 's/[^[:digit:]]//g' | cut -c-2 )"
22 COVER_DIR_NAME="./tests/ci/"
26 echo "Running flake8 ... "
27 logfile=test_results.log
28 if [ $FILE_OPTION == "f" ]; then
29 flake8 yardstick > $logfile
36 if [ $FILE_OPTION == "f" ]; then
37 echo "Results in $logfile"
47 echo "Get external libs needed for unit test"
49 echo "Running unittest ... "
50 if [ $FILE_OPTION == "f" ]; then
51 python -m unittest discover -v -s tests/unit > $logfile 2>&1
53 python -m unittest discover -v -s tests/unit
57 if [ $FILE_OPTION == "f" ]; then
58 echo "FAILED, results in $logfile"
62 if [ $FILE_OPTION == "f" ]; then
63 echo "OK, results in $logfile"
69 # don't re-run coverage on both py27 py3, it takes too long
70 if [[ -z $SKIP_COVERAGE ]] ; then
71 source $COVER_DIR_NAME/cover.sh
76 run_functional_test() {
78 mkdir -p .testrepository
79 python -m subunit.run discover tests/functional > .testrepository/subunit.log
81 subunit2pyunit < .testrepository/subunit.log
83 subunit-stats < .testrepository/subunit.log
85 if [ $EXIT_CODE -ne 0 ]; then