ENH: foamRunTutorials -dry-run option

- for tracing tutorials execution
This commit is contained in:
Mark Olesen 2022-06-14 12:38:33 +02:00
parent 601f541091
commit 96ece1ef35
3 changed files with 46 additions and 13 deletions

View File

@ -44,6 +44,7 @@ options:
-serial Prefer Allrun-serial if available
-parallel Prefer Allrun-parallel if available
-test Prefer Alltest script, pass -test argument to scripts
-dry-run Only report which script to run
-self Avoid initial Allrun / Alltest scripts
(prevent infinite recursion)
-help Print the usage
@ -75,7 +76,7 @@ die()
#------------------------------------------------------------------------------
# Parse options
unset passArgs runTest runType skipSelf
unset optDryRun passArgs runTest runType skipSelf
while [ "$#" -gt 0 ]
do
@ -95,7 +96,7 @@ do
;;
-test)
passArgs="-test"
passArgs="$passArgs${passArgs:+ }$1"
runTest=true
;;
@ -107,6 +108,11 @@ do
echo "$0: unknown setting: $1" 1>&2
;;
-dry-run)
passArgs="$passArgs${passArgs:+ }$1"
optDryRun="(dry-run) "
;;
-case=*)
caseDir="${1#*=}"
;;
@ -142,7 +148,12 @@ then
# Use specialized script(s)
if [ -n "$runTest" ] && [ -f ./Alltest ]
then
./Alltest $passArgs $*
if [ -n "$optDryRun" ]
then
echo "${optDryRun} Alltest: $PWD" 1>&2
else
./Alltest $passArgs $*
fi
exit "$?"
elif [ -f ./Allrun-optional ]
then
@ -154,7 +165,12 @@ then
allRun="Allrun-$runType"
if [ -f ./"$allRun" ]
then
./"$allRun" $passArgs $*
if [ -n "$optDryRun" ]
then
echo "${optDryRun} $allRun: $PWD" 1>&2
else
./"$allRun" $passArgs $*
fi
exit "$?"
fi
fi
@ -164,7 +180,12 @@ then
do
if [ -f ./"$allRun" ]
then
./"$allRun" $passArgs $*
if [ -n "$optDryRun" ]
then
echo "${optDryRun} $allRun: $PWD" 1>&2
else
./"$allRun" $passArgs $*
fi
exit "$?"
fi
done
@ -174,23 +195,35 @@ fi
if [ -d system ]
then
# Run normal case with blockMesh and the application
runApplication blockMesh
runApplication $(getApplication)
if [ -n "$optDryRun" ]
then
echo "${optDryRun} blockMesh + application: $PWD" 1>&2
else
runApplication blockMesh
runApplication $(getApplication)
fi
else
# Loop over sub-directories and compile any applications
# Compile any applications in sub-directories
for caseName in *
do
if [ -d "$caseName/Make" ]
then
( compileApplication "$caseName" )
if [ -n "$optDryRun" ]
then
echo "${optDryRun} compile $caseName" 1>&2
else
( compileApplication "$caseName" )
fi
fi
done
# Loop over sub-directories
subdirs=$(for d in *; do [ -d "$d" ] && echo "$d"; done | xargs)
# Run all cases which have not already been run
"$make" -k -f "${WM_PROJECT_DIR:?}"/bin/tools/MakefileDirs \
"$make" ${optDryRun:+--no-print-directory} \
-k -f "${WM_PROJECT_DIR:?}"/bin/tools/MakefileDirs \
FOAM_TARGETS="$subdirs" \
FOAM_APP="$thisScript" \
FOAM_ARGS="$passArgs ${runType:+--run=$runType} $*"

View File

@ -1,6 +1,6 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/LogFunctions # Tutorial log-file functions
. "${WM_PROJECT_DIR:?}"/bin/tools/LogFunctions # Tutorial log-file functions
#------------------------------------------------------------------------------
echo "--------"
@ -10,7 +10,7 @@ buildDir="${WM_PROJECT_DIR}/build/${WM_OPTIONS}/${PWD##*/}"
if [ -d "$buildDir" ]
then
echo "Removing old build directory: $buildDir" 1>&2
rm -rf $buildDir
rm -rf -- "$buildDir"
fi
removeLogs

View File

@ -1,6 +1,6 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/LogFunctions # Tutorial log-file functions
. "${WM_PROJECT_DIR:?}"/bin/tools/LogFunctions # Tutorial log-file functions
#------------------------------------------------------------------------------
# Collect log files as 'testLoopReport'