From e371956c72130cb683dac90d951d3ed5a2c22dbe Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 29 Jan 2018 11:32:17 -0500 Subject: [PATCH] Runtest.sh improvements; reduce CircleCI test time runtests.sh: show total elapsed time. Be smart about when patterns are entered as a parameter --- test/stdlib/runtests.sh | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/test/stdlib/runtests.sh b/test/stdlib/runtests.sh index 375cdaf8..538899f9 100755 --- a/test/stdlib/runtests.sh +++ b/test/stdlib/runtests.sh @@ -1,6 +1,19 @@ #!/bin/bash me=${BASH_SOURCE[0]} +function displaytime { + local T=$1 + local D=$((T/60/60/24)) + local H=$((T/60/60%24)) + local M=$((T/60%60)) + local S=$((T%60)) + (( $D > 0 )) && printf '%d days ' $D + (( $H > 0 )) && printf '%d hours ' $H + (( $M > 0 )) && printf '%d minutes ' $M + (( $D > 0 || $H > 0 || $M > 0 )) && printf 'and ' + printf '%d seconds\n' $S +} + # Python version setup FULLVERSION=$(pyenv local) PYVERSION=${FULLVERSION%.*} @@ -111,10 +124,16 @@ typeset -i i=0 typeset -i allerrs=0 if [[ -n $1 ]] ; then files=$1 - SKIP_TESTS=() + typeset -a files_ary=( $(echo $1) ) + if (( ${#files_ary[@]} == 1 )) ; then + SKIP_TESTS=() + fi else files=test_*.py fi + +typeset -i ALL_FILES_STARTTIME=$(date +%s) + for file in $files; do # AIX bash doesn't grok [[ -v SKIP... ]] [[ ${SKIP_TESTS[$file]} == 1 ]] && continue @@ -155,5 +174,11 @@ for file in $files; do exit $allerrs fi done -echo "Ran $i tests" +typeset -i ALL_FILES_ENDTIME=$(date +%s) + +(( time_diff = ALL_FILES_ENDTIME - ALL_FILES_STARTTIME)) + +printf "Ran $i tests in " +displaytime $time_diff + exit $allerrs