mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: improve overwrite behaviour of tutorials/Alltest (#1364)
Modifications to help avoid inadvertent overwriting of tutorialsTest: - new '-force' option to overwrite existing directory - generate a 'tutorialsTest/Alltest' script that disallows the possibilty of self-recursion
This commit is contained in:
committed by
Andrew Heather
parent
d6d95c33bc
commit
c54c4c8c62
@ -33,16 +33,16 @@ usage()
|
|||||||
usage: ${0##*/} [OPTION]
|
usage: ${0##*/} [OPTION]
|
||||||
|
|
||||||
options:
|
options:
|
||||||
|
-force Force overwrite of existing tutorialsTest directory
|
||||||
|
-debug Adjust DebugSwitches (fvSchemes, solution)
|
||||||
|
-default Sets up a default scheme on all schemes
|
||||||
-git Use git to retrieve the tutorials
|
-git Use git to retrieve the tutorials
|
||||||
-no-git Do not use git to retrieve the tutorials
|
-no-git Do not use git to retrieve the tutorials
|
||||||
-debug Adjust DebugSwitches (fvSchemes, solution)
|
-root dir Root directory to start tests from (non-git only)
|
||||||
-root dir Specify root directory to run tests from
|
|
||||||
-default Sets up a default scheme on all schemes
|
|
||||||
-help Print the usage
|
-help Print the usage
|
||||||
|
|
||||||
Quickly tests the tutorials and writes out the scheme/solver information.
|
Quickly tests the tutorials and writes out the scheme/solver information.
|
||||||
The default is to detect and use 'git' if possible to obtain a fresh set
|
Detects and uses 'git' to obtain a fresh set of files when possible.
|
||||||
of tutorial files. This can be overridden with -git or -no-git options.
|
|
||||||
|
|
||||||
USAGE
|
USAGE
|
||||||
exit 1
|
exit 1
|
||||||
@ -63,10 +63,11 @@ die()
|
|||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
ROOT="./"
|
rootDir="./"
|
||||||
adjustDebugSwitches=false
|
adjustDebugSwitches=false
|
||||||
useDefaultSchemes=false
|
useDefaultSchemes=false
|
||||||
useGit=auto
|
useGit=auto
|
||||||
|
unset optForce
|
||||||
|
|
||||||
# Parse options
|
# Parse options
|
||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
@ -75,9 +76,12 @@ do
|
|||||||
-h | -help)
|
-h | -help)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
|
-f | -force)
|
||||||
|
optForce=true
|
||||||
|
;;
|
||||||
-r | -root)
|
-r | -root)
|
||||||
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
|
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
|
||||||
ROOT="$2"
|
rootDir="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-git)
|
-git)
|
||||||
@ -165,7 +169,6 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
TUTORIALS_DIR=$ROOT
|
|
||||||
TEST_RUN_DIR=../tutorialsTest
|
TEST_RUN_DIR=../tutorialsTest
|
||||||
FV_SCHEMES=\
|
FV_SCHEMES=\
|
||||||
" \
|
" \
|
||||||
@ -187,8 +190,15 @@ SOLVERS_TEMP="FvSolution.temp"
|
|||||||
|
|
||||||
if [ -d "$TEST_RUN_DIR" ]
|
if [ -d "$TEST_RUN_DIR" ]
|
||||||
then
|
then
|
||||||
echo "Removing old directory: $TEST_RUN_DIR" 1>&2
|
if [ "$optForce" = true ]
|
||||||
rm -rf $TEST_RUN_DIR
|
then
|
||||||
|
echo "Removing old directory: $TEST_RUN_DIR" 1>&2
|
||||||
|
rm -rf $TEST_RUN_DIR
|
||||||
|
else
|
||||||
|
echo "Directory already exists: $TEST_RUN_DIR" 1>&2
|
||||||
|
echo " use -force to remove" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove old build/ directory
|
# Remove old build/ directory
|
||||||
@ -228,17 +238,21 @@ fi
|
|||||||
if [ -n "$gitbase" ]
|
if [ -n "$gitbase" ]
|
||||||
then
|
then
|
||||||
echo "Copying the tutorials from current git branch" 1>&2
|
echo "Copying the tutorials from current git branch" 1>&2
|
||||||
mkdir -p "${TEST_RUN_DIR}"
|
mkdir -p "$TEST_RUN_DIR"
|
||||||
( cd "$gitbase/tutorials" && git archive --format=tar HEAD . ) | \
|
( cd "$gitbase/tutorials" && git archive --format=tar HEAD . ) | \
|
||||||
( cd "$TEST_RUN_DIR" && tar -xf - )
|
( cd "$TEST_RUN_DIR" && tar -xf - )
|
||||||
else
|
else
|
||||||
echo "Copying the tutorials directory" 1>&2
|
echo "Copying the tutorials directory" 1>&2
|
||||||
cp -a "$TUTORIALS_DIR" "$TEST_RUN_DIR"
|
cp -a "$rootDir" "$TEST_RUN_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "${TEST_RUN_DIR}" || exit 1
|
cd "$TEST_RUN_DIR" || exit 1
|
||||||
|
|
||||||
echo 1>&2
|
|
||||||
|
# Generate Alltest script (replacement for this one)
|
||||||
|
echo "Generating Alltest script" 1>&2
|
||||||
|
echo '#!/bin/sh' >| Alltest
|
||||||
|
echo 'exec "${0%/*}/Allrun" -test "$@"' >> Alltest
|
||||||
|
|
||||||
|
|
||||||
# Adjust etc controlDict, and clean up on termination and on Ctrl-C
|
# Adjust etc controlDict, and clean up on termination and on Ctrl-C
|
||||||
|
|||||||
Reference in New Issue
Block a user