From ff37bfa782841d52ed46c11b0331a5b8fee8ae18 Mon Sep 17 00:00:00 2001 From: Thomas Fetzer <thomas.fetzer@iws.uni-stuttgart.de> Date: Mon, 13 Apr 2015 10:54:49 +0000 Subject: [PATCH] [bin] improved runTest.sh that also an exact compare between two files can be performed fixed typo in fuzzycompare reviewed by martinb git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@14547 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- bin/fuzzycomparevtu.py | 2 +- bin/runTest.sh | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/bin/fuzzycomparevtu.py b/bin/fuzzycomparevtu.py index e58387748b..07a486d021 100644 --- a/bin/fuzzycomparevtu.py +++ b/bin/fuzzycomparevtu.py @@ -68,7 +68,7 @@ parser.add_argument('vtu_file_2', type=open, parser.add_argument('-r', '--relative', type=float, default=1e-2, help='maximum relative error (default=1e-2)') parser.add_argument('-a', '--absolute', type=float, default=1e-9, - help='maximum relative error (default=1e-9)') + help='maximum absolute error (default=1e-9)') args = parser.parse_args() # fuzzy compare diff --git a/bin/runTest.sh b/bin/runTest.sh index 2731088053..57413c4104 100755 --- a/bin/runTest.sh +++ b/bin/runTest.sh @@ -4,16 +4,20 @@ # # Usage: # -# runTest.sh FUZZY_COMPARE REFERENCE_RESULT_FILE TEST_RESULT_FILE TEST_BINARY TEST_ARGS +# runTest.sh COMPAREFLAG/SCRIPT REFERENCE_RESULT_FILE TEST_RESULT_FILE TEST_BINARY TEST_ARGS # function usage() { echo "Usage:" echo - echo "runTest.sh FUZZY_COMPARE REFERENCE_RESULT_FILE TEST_RESULT_FILE TEST_BINARY [TEST_ARGS]" + echo "runTest.sh COMPAREFLAG/SCRIPT REFERENCE_RESULT_FILE TEST_RESULT_FILE TEST_BINARY [TEST_ARGS]" + echo "COMPAREFLAG: fuzzyvtu - uses the fuzzycomparevtu.py script" + echo " exact - uses diff for exact compare of two files" + echo " PATH_TO_SCRIPT - tries to execute the custom script" }; -FUZZY_COMPARE="$1" +CMAKE_SOURCE_DIR=$(dirname "$0") +COMPARE_FLAG="$1" REFERENCE_RESULT="$2" TEST_RESULT="$3" TEST_BINARY="$4" @@ -56,7 +60,31 @@ if ! test -r "$TEST_RESULT"; then exit 1 fi -if ! python "$FUZZY_COMPARE" "$REFERENCE_RESULT" "$TEST_RESULT"; then +# running the compare script +NOT_EQUAL=false +if [ "$COMPARE_FLAG" = "fuzzyvtu" -o \ + "$COMPARE_FLAG" = "$CMAKE_SOURCE_DIR/fuzzycomparevtu.py" ]; then + if ! python $CMAKE_SOURCE_DIR/fuzzycomparevtu.py "$REFERENCE_RESULT" "$TEST_RESULT"; then + NOT_EQUAL=true + fi +elif [ "$COMPARE_FLAG" = "exact" ]; then + if ! diff "$REFERENCE_RESULT" "$TEST_RESULT"; then + NOT_EQUAL=true + fi +elif [ -e "$COMPARE_FLAG" ]; then + if ! $COMPARE_FLAG "$REFERENCE_RESULT" "$TEST_RESULT"; then + NOT_EQUAL=true + fi +else + echo + echo "ERROR: $0 was not able to run the compare script:" + echo " $COMPARE_FLAG" + echo + exit 2 +fi + +# printing error message in case of failure +if [ "$NOT_EQUAL" = "true" ]; then echo "The files \"$TEST_RESULT\" and \"$REFERENCE_RESULT\" are different." echo "Make sure the contents of \"$TEST_RESULT\" are still valid and " echo "make it the reference result if necessary." -- GitLab