diff options
-rwxr-xr-x | cmake/basictest | 35 | ||||
-rw-r--r-- | test/CMakeLists.txt | 17 |
2 files changed, 40 insertions, 12 deletions
diff --git a/cmake/basictest b/cmake/basictest index 575f1c87..5e9010a0 100755 --- a/cmake/basictest +++ b/cmake/basictest @@ -1,9 +1,18 @@ #!/bin/sh +# Use this for debugging the test cases. +# The resulting textual output will not destroy the test cases. +set -x +# After test case execution, the output can be found in +# build/Testing/Temporary/LastTest.log + export PATH=$PATH:/c/MinGW/msys/1.0/bin +export GAWKEXE=$1 +export TESTCASE=$2 +export OPTION=$3 TESTHOME=$(dirname ${0})/../test export AWKPATH=${TESTHOME} -export AWKLIBPATH=$(dirname ${1})/extension/ +export AWKLIBPATH=$(dirname ${GAWKEXE})/extension/ export LANG=C # Is this shell running in a native MinGW shell (MSYS) ? if test -n "$COMSPEC"; then @@ -13,11 +22,27 @@ else # This is a shell running in Unix environment. COMPARE="cmp" fi -if test -r ${TESTHOME}/${2}.in + +# Each test case that cannot be handle in the "standard way" shall +# be implemented as a function here. +function testext() { + $GAWKEXE '/^(@load|BEGIN)/,/^}/' ${TESTHOME}/../extension/testext.c > testext.awk + $GAWKEXE -f ${TESTCASE}.awk > ${TESTHOME}/_${TESTCASE} 2>&1 || echo EXIT CODE: $? >> ${TESTHOME}/_${TESTCASE} + rm -f testext.awk +} + +# Is this test case implemented as a function ? +if [ "$( type -t $TESTCASE )" = "function" ] +then + $TESTCASE +# If no function exists, then treat the test case in standard way. +elif test -r ${TESTHOME}/${TESTCASE}.in +# Any existing .in file will be redirected to standard input. then - $1 $3 -f ${2}.awk < ${TESTHOME}/${2}.in > ${TESTHOME}/_${2} 2>&1 || echo EXIT CODE: $? >> ${TESTHOME}/_${2} + $GAWKEXE ${OPTION} -f ${TESTCASE}.awk < ${TESTHOME}/${TESTCASE}.in > ${TESTHOME}/_${TESTCASE} 2>&1 || echo EXIT CODE: $? >> ${TESTHOME}/_${TESTCASE} else - $1 $3 -f ${2}.awk > ${TESTHOME}/_${2} 2>&1 || echo EXIT CODE: $? >> ${TESTHOME}/_${2} + $GAWKEXE ${OPTION} -f ${TESTCASE}.awk > ${TESTHOME}/_${TESTCASE} 2>&1 || echo EXIT CODE: $? >> ${TESTHOME}/_${TESTCASE} fi -${COMPARE} ${TESTHOME}/${2}.ok ${TESTHOME}/_${2} && rm -f ${TESTHOME}/_${2} +# Compare the actual output with the expected (correct) output. +${COMPARE} ${TESTHOME}/${TESTCASE}.ok ${TESTHOME}/_${TESTCASE} && rm -f ${TESTHOME}/_${TESTCASE} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8e0eb391..6b085e08 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -43,11 +43,11 @@ foreach(testgroup ${ALL_GROUPS} ) # Some test cases are special, treat them accordingly. foreach(testcase ${ONE_GROUP} ) set(options "") - set(suffix "") + set(file_suffix "") if(${testcase} STREQUAL lintold) set(options "--lint-old") elseif( - ${testcase} STREQUAL defref OR ${testcase} STREQUAL fmtspcl OR + ${testcase} STREQUAL defref OR ${testcase} STREQUAL lintwarn OR ${testcase} STREQUAL noeffect OR ${testcase} STREQUAL nofmtch OR ${testcase} STREQUAL shadow OR ${testcase} STREQUAL uninit2 OR ${testcase} STREQUAL uninit3 OR @@ -63,7 +63,7 @@ foreach(testgroup ${ALL_GROUPS} ) ${testcase} STREQUAL rsstart2 OR ${testcase} STREQUAL strftime OR ${testcase} STREQUAL readdir ) - set(suffix "_HANGS") + set(file_suffix "_HANGS") # These are the test cases that fail. # Some of them may reveal genuine bugs. # Most of them fail because they need to be invoked with a special parameter. @@ -104,13 +104,16 @@ foreach(testgroup ${ALL_GROUPS} ) ${testcase} STREQUAL rsstart3 OR ${testcase} STREQUAL rtlen OR ${testcase} STREQUAL rtlen01 OR ${testcase} STREQUAL rtlenmb OR ${testcase} STREQUAL space OR ${testcase} STREQUAL strftlng OR - ${testcase} STREQUAL symtab6 OR ${testcase} STREQUAL symtab8 OR - ${testcase} STREQUAL testext + ${testcase} STREQUAL symtab6 OR ${testcase} STREQUAL symtab8 ) - set(suffix "_FAILS") + set(file_suffix "_FAILS") endif() - add_test(${testcase} ${SHELL_PREFIX} ${CMAKE_SOURCE_DIR}/cmake/basictest ${CMAKE_BINARY_DIR}/gawk ${testcase}${suffix} ${options} ) + if ("${file_suffix}" STREQUAL "") + add_test("${testgroup}.${testcase}" ${SHELL_PREFIX} ${CMAKE_SOURCE_DIR}/cmake/basictest ${CMAKE_BINARY_DIR}/gawk ${testcase}${file_suffix} ${options} ) + else() + message(STATUS "Skipping test case ${testgroup}.${testcase}") + endif() endforeach(testcase) endforeach(testgroup) |