From b0810ef3913cb13fb704ada4ac93ea11fd3fab21 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Wed, 10 Jun 2020 10:17:44 +0800 Subject: [PATCH] make test-all.sh flexible to manually execute. --- tests/test-all.sh | 101 +++++++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 46 deletions(-) diff --git a/tests/test-all.sh b/tests/test-all.sh index cee638e03c..485c852dc5 100755 --- a/tests/test-all.sh +++ b/tests/test-all.sh @@ -24,65 +24,74 @@ GREEN_DARK='\033[0;32m' GREEN_UNDERLINE='\033[4;32m' NC='\033[0m' -echo "### run TSIM test case ###" -cd script - -[ -f out.log ] && rm -f out.log - -if [ "$1" == "cron" ]; then - echo "### run TSIM regression test ###" - runSimCaseOneByOne regressionSuite.sim -elif [ "$1" == "full" ]; then - echo "### run TSIM full test ###" - runSimCaseOneByOne fullGeneralSuite.sim -else - echo "### run TSIM smoke test ###" - runSimCaseOneByOne basicSuite.sim -fi +totalFailed=0 +totalPyFailed=0 -totalSuccess=`grep 'success' out.log | wc -l` -totalBasic=`grep success out.log | grep Suite | wc -l` -if [ "$totalSuccess" -gt "0" ]; then - totalSuccess=`expr $totalSuccess - $totalBasic` -fi +current_dir=`pwd` -echo -e "${GREEN} ### Total $totalSuccess TSIM case(s) succeed! ### ${NC}" +if [ "$2" != "python" ]; then + echo "### run TSIM test case ###" + cd $current_dir/script -totalFailed=`grep 'failed\|fault' out.log | wc -l` -# echo -e "${RED} ### Total $totalFailed TSIM case(s) failed! ### ${NC}" + [ -f out.log ] && rm -f out.log + if [ "$1" == "cron" ]; then + echo "### run TSIM regression test ###" + runSimCaseOneByOne regressionSuite.sim + elif [ "$1" == "full" ]; then + echo "### run TSIM full test ###" + runSimCaseOneByOne fullGeneralSuite.sim + else + echo "### run TSIM smoke test ###" + runSimCaseOneByOne basicSuite.sim + fi -if [ "$totalFailed" -ne "0" ]; then - echo -e "${RED} ### Total $totalFailed TSIM case(s) failed! ### ${NC}" + totalSuccess=`grep 'success' out.log | wc -l` + totalBasic=`grep success out.log | grep Suite | wc -l` -# exit $totalFailed -fi + if [ "$totalSuccess" -gt "0" ]; then + totalSuccess=`expr $totalSuccess - $totalBasic` + fi -echo "### run Python test case ###" -cd ../pytest + echo -e "${GREEN} ### Total $totalSuccess TSIM case(s) succeed! ### ${NC}" -[ -f pytest-out.log ] && rm -f pytest-out.log + totalFailed=`grep 'failed\|fault' out.log | wc -l` +# echo -e "${RED} ### Total $totalFailed TSIM case(s) failed! ### ${NC}" -if [ "$1" == "cron" ]; then - echo "### run Python regression test ###" - runPyCaseOneByOne regressiontest.sh -elif [ "$1" == "full" ]; then - echo "### run Python full test ###" - runPyCaseOneByOne fulltest.sh -else - echo "### run Python smoke test ###" - runPyCaseOneByOne smoketest.sh -fi -totalPySuccess=`grep 'successfully executed' pytest-out.log | wc -l` + if [ "$totalFailed" -ne "0" ]; then + echo -e "${RED} ### Total $totalFailed TSIM case(s) failed! ### ${NC}" -if [ "$totalPySuccess" -gt "0" ]; then - echo -e "${GREEN} ### Total $totalPySuccess python case(s) succeed! ### ${NC}" +# exit $totalFailed + fi fi -totalPyFailed=`grep 'failed\|fault' pytest-out.log | wc -l` -if [ "$totalPyFailed" -ne "0" ]; then - echo -e "${RED} ### Total $totalPyFailed python case(s) failed! ### ${NC}" +if [ "$2" != "sim" ]; then + echo "### run Python test case ###" + cd $current_dir/pytest + + [ -f pytest-out.log ] && rm -f pytest-out.log + + if [ "$1" == "cron" ]; then + echo "### run Python regression test ###" + runPyCaseOneByOne regressiontest.sh + elif [ "$1" == "full" ]; then + echo "### run Python full test ###" + runPyCaseOneByOne fulltest.sh + else + echo "### run Python smoke test ###" + runPyCaseOneByOne smoketest.sh + fi + totalPySuccess=`grep 'successfully executed' pytest-out.log | wc -l` + + if [ "$totalPySuccess" -gt "0" ]; then + echo -e "${GREEN} ### Total $totalPySuccess python case(s) succeed! ### ${NC}" + fi + + totalPyFailed=`grep 'failed\|fault' pytest-out.log | wc -l` + if [ "$totalPyFailed" -ne "0" ]; then + echo -e "${RED} ### Total $totalPyFailed python case(s) failed! ### ${NC}" # exit $totalPyFailed + fi fi exit $(($totalFailed + $totalPyFailed)) -- GitLab