Skip to content
Snippets Groups Projects
Commit c35077ae authored by Patrick Baudin's avatar Patrick Baudin
Browse files

[Script] improves 'bin/tests.sh --verbose'

parent 6012a7aa
No related branches found
No related tags found
No related merge requests found
...@@ -27,7 +27,8 @@ VERBOSE= ...@@ -27,7 +27,8 @@ VERBOSE=
UPDATE= UPDATE=
LOGS= LOGS=
TESTS= TESTS=
COUNT=
LOG_ERR=.test-errors.log
FRAMAC_WP_CACHE_GIT=git@git.frama-c.com:frama-c/wp-cache.git FRAMAC_WP_CACHE_GIT=git@git.frama-c.com:frama-c/wp-cache.git
...@@ -120,17 +121,16 @@ function Cmd ...@@ -120,17 +121,16 @@ function Cmd
function SetEnv function SetEnv
{ {
if [ "$FRAMAC_WP_CACHE" = "" ] if [ "$FRAMAC_WP_CACHE" = "" ]; then
then
FRAMAC_WP_CACHE=offline FRAMAC_WP_CACHE=offline
Echo "Set FRAMAC_WP_CACHE=$FRAMAC_WP_CACHE" Echo "Set FRAMAC_WP_CACHE=$FRAMAC_WP_CACHE"
fi fi
if [ "$FRAMAC_WP_CACHEDIR" = "" ] if [ "$FRAMAC_WP_CACHEDIR" = "" ]; then
then
FRAMAC_WP_CACHEDIR=./.wp-cache FRAMAC_WP_CACHEDIR=./.wp-cache
Echo "Set FRAMAC_WP_CACHEDIR=$FRAMAC_WP_CACHEDIR" Echo "Set FRAMAC_WP_CACHEDIR=$FRAMAC_WP_CACHEDIR"
fi fi
} }
function CloneCache function CloneCache
...@@ -147,6 +147,25 @@ function PullCache ...@@ -147,6 +147,25 @@ function PullCache
Run git -C $FRAMAC_WP_CACHEDIR pull --rebase 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 # --- Test Dir Processing
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
...@@ -169,7 +188,7 @@ function TestDir ...@@ -169,7 +188,7 @@ function TestDir
;; ;;
esac esac
Head "Running test on directory $1 $CFG" Head "Running test on directory $1 $CFG"
Run dune build @$ALIAS TestAlias @$ALIAS
} }
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
...@@ -192,14 +211,13 @@ function TestFile ...@@ -192,14 +211,13 @@ function TestFile
CFG="(config $CONFIG)" CFG="(config $CONFIG)"
;; ;;
esac esac
if [ "$LOGS" = "yes" ] if [ "$LOGS" = "yes" ]; then
then
ALIAS=$DIR/$RESULT/$FILE ALIAS=$DIR/$RESULT/$FILE
else else
ALIAS=$DIR/$RESULT/${FILE%.*}.wtests ALIAS=$DIR/$RESULT/${FILE%.*}.wtests
fi fi
Head "Running test on file $1 $CFG" Head "Running test on file $1 $CFG"
Cmd dune build @$ALIAS TestAlias @$ALIAS
} }
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
...@@ -210,14 +228,15 @@ function RunTests ...@@ -210,14 +228,15 @@ function RunTests
{ {
while [ "$1" != "" ] while [ "$1" != "" ]
do do
if [ -d $1 ] if [ -d $1 ]; then
then
TestDir $1 TestDir $1
elif [ -f $1 ] elif [ -f $1 ]; then
then
TestFile $1 TestFile $1
else 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 fi
shift shift
done done
...@@ -231,21 +250,27 @@ function RunTests ...@@ -231,21 +250,27 @@ function RunTests
function CountTests function CountTests
{ {
#-- Count number of .res.log files #-- 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 BUILD=_build/default
Head "Number of .res.log files by test directory..." Head "Number of *.res.log files by test directory..."
NB= NB=
for dir in tests src/plugins/*/tests ; do 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="$((find $BUILD/$dir -name \*.res.log 2> /dev/null) | wc -l)"
[ "$NB" = "0"] || echo "- $dir= $NB" [ "$NB" = "0" ] || echo "- $dir= $NB"
fi fi
done done
[ "$NB" != "" ] || echo "- <none>" [ "$NB" != "" ] || echo "- <none>"
fi fi
#-- Check wp-cache status #-- Check wp-cache status
if [ "$UPDATE" = "yes" ]; then if [ "$UPDATE" = "yes" ]; then
Head "Check $FRAMAC_WP_CACHEDIR status" Head "Check $FRAMAC_WP_CACHEDIR status"
...@@ -296,9 +321,6 @@ do ...@@ -296,9 +321,6 @@ do
"-a"|"--all") "-a"|"--all")
TESTS="tests src/plugins/*/tests" TESTS="tests src/plugins/*/tests"
;; ;;
"-n"|"--count")
COUNT=yes
;;
*) *)
TESTS+=" $1" TESTS+=" $1"
;; ;;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment