From c35077ae77cac7c576ee7a69ef67a171ba9aa99d Mon Sep 17 00:00:00 2001 From: Patrick Baudin <patrick.baudin@cea.fr> Date: Fri, 1 Jul 2022 11:35:00 +0200 Subject: [PATCH] [Script] improves 'bin/tests.sh --verbose' --- bin/test.sh | 64 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/bin/test.sh b/bin/test.sh index c613c255d7d..dc6612ddbfc 100755 --- a/bin/test.sh +++ b/bin/test.sh @@ -27,7 +27,8 @@ VERBOSE= UPDATE= LOGS= TESTS= -COUNT= + +LOG_ERR=.test-errors.log FRAMAC_WP_CACHE_GIT=git@git.frama-c.com:frama-c/wp-cache.git @@ -120,17 +121,16 @@ function Cmd function SetEnv { - if [ "$FRAMAC_WP_CACHE" = "" ] - then + if [ "$FRAMAC_WP_CACHE" = "" ]; then FRAMAC_WP_CACHE=offline Echo "Set FRAMAC_WP_CACHE=$FRAMAC_WP_CACHE" fi - if [ "$FRAMAC_WP_CACHEDIR" = "" ] - then + if [ "$FRAMAC_WP_CACHEDIR" = "" ]; then FRAMAC_WP_CACHEDIR=./.wp-cache Echo "Set FRAMAC_WP_CACHEDIR=$FRAMAC_WP_CACHEDIR" fi + } function CloneCache @@ -147,6 +147,25 @@ function PullCache Run git -C $FRAMAC_WP_CACHEDIR pull --rebase } +# -------------------------------------------------------------------------- +# --- Test Dir Alias +# -------------------------------------------------------------------------- + +rm -rf $LOG_ERR +function TestAlias +{ + + if [ "$VERBOSE" != "yes" ]; then + Run dune build $@ + elif [ "$LOG_ERR" = "" ]; then + Run build --display short + else + # note: the Run function cannot performs redirection + echo "> build --display short $@ 2> >(tee -a $LOG_ERR >&2)" + dune build --display short $@ 2> >(tee -a $LOG_ERR >&2) + fi +} + # -------------------------------------------------------------------------- # --- Test Dir Processing # -------------------------------------------------------------------------- @@ -169,7 +188,7 @@ function TestDir ;; esac Head "Running test on directory $1 $CFG" - Run dune build @$ALIAS + TestAlias @$ALIAS } # -------------------------------------------------------------------------- @@ -192,14 +211,13 @@ function TestFile CFG="(config $CONFIG)" ;; esac - if [ "$LOGS" = "yes" ] - then + if [ "$LOGS" = "yes" ]; then ALIAS=$DIR/$RESULT/$FILE else ALIAS=$DIR/$RESULT/${FILE%.*}.wtests fi Head "Running test on file $1 $CFG" - Cmd dune build @$ALIAS + TestAlias @$ALIAS } # -------------------------------------------------------------------------- @@ -210,14 +228,15 @@ function RunTests { while [ "$1" != "" ] do - if [ -d $1 ] - then + if [ -d $1 ]; then TestDir $1 - elif [ -f $1 ] - then + elif [ -f $1 ]; then TestFile $1 else - ErrorUsage "ERROR: don't known what to do with '$1'" + case $1 in + @*) Head "Running test on alias $1"; TestAlias $1;; + *) ErrorUsage "ERROR: don't known what to do with '$1'";; + esac fi shift done @@ -231,21 +250,27 @@ function RunTests function CountTests { #-- Count number of .res.log files - if [ "$COUNT" = "yes" ]; then + if [ "$VERBOSE" = "yes" ]; then + + if [ -f "$LOG_ERR" ]; then + echo "# Number of executed frama-c-wtests= $(grep -c "^frama-c-wtests " $LOG_ERR)" + Cmd rm -f $LOG_ERR + fi BUILD=_build/default - Head "Number of .res.log files by test directory..." + Head "Number of *.res.log files by test directory..." NB= for dir in tests src/plugins/*/tests ; do - if [ ! -d "$dir" ] ; then + if [ -d "$dir" ]; then NB="$((find $BUILD/$dir -name \*.res.log 2> /dev/null) | wc -l)" - [ "$NB" = "0"] || echo "- $dir= $NB" + [ "$NB" = "0" ] || echo "- $dir= $NB" fi done [ "$NB" != "" ] || echo "- <none>" fi + #-- Check wp-cache status if [ "$UPDATE" = "yes" ]; then Head "Check $FRAMAC_WP_CACHEDIR status" @@ -296,9 +321,6 @@ do "-a"|"--all") TESTS="tests src/plugins/*/tests" ;; - "-n"|"--count") - COUNT=yes - ;; *) TESTS+=" $1" ;; -- GitLab