CONFIG: add date and paths information for tutorial Allrun script

STYLE: replace short-circuit Allrun script with Alltest
This commit is contained in:
Mark Olesen 2021-09-22 15:18:36 +02:00
parent 134aaee91a
commit fcd7423fa8
8 changed files with 109 additions and 86 deletions

View File

@ -75,6 +75,7 @@ cleanType=auto
if [ "$#" -gt 0 ]
then
unset caseDir
case "$1" in
(- | --)
shift
@ -102,31 +103,32 @@ then
;;
-case=*)
caseName="${1#*=}"
cd "$caseName" 2>/dev/null || {
echo "${0##*}: No such directory $caseName" 1>&2
exit 2
}
caseDir="${1#*=}"
;;
-case)
caseDir="$2"
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
shift
cd "$1" 2>/dev/null || {
echo "${0##*}: No such directory $1" 1>&2
exit 2
}
;;
-self* | -skipFirst)
skipSelf=true
;;
-*) die "unknown option: $1" ;;
*)
cd "$1" 2>/dev/null || {
echo "${0##*}: No such directory $1" 1>&2
exit 2
}
caseDir="$1"
;;
esac
shift
if [ -n "$caseDir" ]
then
cd "$caseDir" 2>/dev/null || {
echo "${0##*/}: No such directory $caseDir" 1>&2
exit 2
}
fi
fi

View File

@ -78,6 +78,7 @@ unset passArgs runTests runType skipSelf
while [ "$#" -gt 0 ]
do
unset caseDir
case "$1" in
(- | --)
shift
@ -106,19 +107,12 @@ do
;;
-case=*)
caseName="${1#*=}"
cd "$caseName" 2>/dev/null || {
echo "${0##*}: No such directory $caseName" 1>&2
exit 2
}
caseDir="${1#*=}"
;;
-case)
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
caseDir="$2"
[ -n "$#" -ge 2 ] || die "'$1' option requires an argument"
shift
cd "$1" 2>/dev/null || {
echo "${0##*}: No such directory $1" 1>&2
exit 2
}
;;
# Avoid infinite recursion when invoked from an Allrun/Alltest script
@ -130,6 +124,14 @@ do
;;
esac
shift
if [ -n "$caseDir" ]
then
cd "$caseDir" 2>/dev/null || {
echo "${0##*/}: No such directory $caseDir" 1>&2
exit 2
}
fi
done

View File

@ -5,7 +5,7 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2017-2019 OpenCFD Ltd.
# Copyright (C) 2017-2021 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -114,7 +114,7 @@ removeLogs()
-name '*.pvs' -o -name '*.foam' -o -name '*.OpenFOAM' \
\) -type f -delete
rm -f logs testLoopReport
rm -f logs testLoopReport log.Allrun log.Alltest
}

View File

@ -6,7 +6,7 @@ cd "${0%/*}" || exit # Run from this directory
echo "--------"
# Remove old build/ directory
buildDir="$WM_PROJECT_DIR/build/${WM_OPTIONS}/${PWD##*/}"
buildDir="${WM_PROJECT_DIR}/build/${WM_OPTIONS}/${PWD##*/}"
if [ -d "$buildDir" ]
then
echo "Removing old build directory: $buildDir" 1>&2
@ -16,7 +16,7 @@ fi
removeLogs
echo "Cleaning tutorials ..."
foamCleanTutorials -self
foamCleanTutorials -self # Run recursively but avoid self
echo "--------"

View File

@ -7,11 +7,10 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2017-2019 OpenCFD Ltd.
# Copyright (C) 2017-2021 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# Allrun
@ -22,21 +21,34 @@
#------------------------------------------------------------------------------
cd "${0%/*}" || exit # Run from this directory
usage()
printHelp()
{
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
usage: ${0##*/} [OPTION]
Usage: ${0##*/} [OPTION]
options:
-collect Collect logs only. Can be useful for aborted runs.
-no-collect Run without collecting logs
-test Pass -test argument to scripts, end of option processing
-- End of option processing
-help print the usage
Run tutorial cases and summarize the outcome as 'testLoopReport'
USAGE
exit 0 # A clean exit
}
# Report error and exit
die()
{
exec 1>&2
echo
echo "Error encountered:"
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
echo
echo "See '${0##*/} -help' for usage"
echo
exit 1
}
@ -47,21 +59,21 @@ unset optCollect
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help*)
usage
('') ;;
(- | --)
shift
break # Stop option parsing
;;
-collect)
optCollect=true
;;
-test) # Known options to pass through
break
;;
-*)
usage "unknown option: $1"
;;
*)
break
(-h | -help* | --help*)
printHelp
;;
-collect) optCollect=true ;;
-no-collect) optCollect=false ;;
-test) break;; # Pass-thru option, and stop option parsing
-*) die "unknown option: $1" ;;
*) break;; # Pass-thru arguments
esac
shift
done
@ -69,11 +81,50 @@ done
#------------------------------------------------------------------------------
. ${WM_PROJECT_DIR:?}/bin/tools/LogFunctions # Tutorial log-file functions
if [ -z "$optCollect" ]
printRunHeader()
{
echo "========================================"
date "+%Y-%m-%d %H:%M:%S %z" 2>/dev/null || echo "date is unknown"
echo "$@: ${WM_PROJECT_DIR##*/}"
echo " $WM_COMPILER ${WM_COMPILER_TYPE:-system} compiler"
echo " ${WM_OPTIONS}, with ${WM_MPLIB} ${FOAM_MPI}"
echo "========================================"
}
printRunEnviron()
{
echo "PATH:$PATH" | sed 's/::*/\n /g'
echo ==
if [ -n "$DYLD_LIBRARY_PATH" ]
then
echo "DYLD_LIBRARY_PATH:$DYLD_LIBRARY_PATH" | sed 's/::*/\n /g'
echo ==
fi
if [ -n "$LD_LIBRARY_PATH" ]
then
echo "LD_LIBRARY_PATH:$LD_LIBRARY_PATH" | sed 's/::*/\n /g'
echo ==
fi
}
if [ "$optCollect" != true ]
then
foamRunTutorials -skipFirst $* # Run recursively
printRunHeader "Starting run" | tee log.Allrun
printRunEnviron | tee -a log.Allrun
foamRunTutorials -self $* # Run recursively but avoid self
printRunHeader "Finishing run" | tee -a log.Allrun
fi
if [ "$optCollect" = false ]
then
echo "Collecting log files - disabled"
else
# Collect log files as 'testLoopReport'
collectLogs
fi
collectLogs
#------------------------------------------------------------------------------

View File

@ -10,20 +10,7 @@
# Copyright (C) 2021 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# plot

View File

@ -9,20 +9,7 @@
# Copyright (C) 2017-2021 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# plot

View File

@ -1,13 +1,7 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
if notTest "$@"
then
foamRunTutorials -skipFirst
else
echo "--- Skipping testing of tutorials in : $PWD" 1>&2
fi
echo "--- Skipping testing of tutorials in : $PWD" 1>&2
#------------------------------------------------------------------------------