summaryrefslogtreecommitdiffstats
path: root/run-tests.sh
diff options
context:
space:
mode:
Diffstat (limited to 'run-tests.sh')
-rwxr-xr-xrun-tests.sh79
1 files changed, 73 insertions, 6 deletions
diff --git a/run-tests.sh b/run-tests.sh
index 39aeab3b624..14512648c03 100755
--- a/run-tests.sh
+++ b/run-tests.sh
@@ -99,18 +99,85 @@ function check_user()
fi
}
+function run_tests()
+{
+ declare -A DONE
+ match()
+ {
+ # Patterns considered valid:
+ # 1. full or partial file/directory names
+ # basic matches tests/basic
+ # basic/afr matches tests/basic/afr
+ # 2. globs
+ # basic/* matches all files and directories in basic
+ # basic/*/ matches subdirectories in basic (afr|ec)
+ # 3. numbered bug matching
+ # 884455 matches bugs/bug-884455.t
+ # 859927 matches bugs/859927, bugs/bug-859927.t
+ # 1015990 matches /bugs/bug-1015990-rep.t, bug-1015990.t
+ # ...lots of other cases accepted as well, since globbing is tricky.
+ local t=$1
+ local mt=$1
+ shift
+ local a
+ local match=1
+ if [ -d $t ] ; then
+ # Allow matching on globs like 'basic/*/'
+ mt=$t/
+ fi
+ for a in "$@" ; do
+ case "$mt" in
+ *$a|*/bugs/$a/|*/bugs/$a.t|*/bugs/bug-$a.t|*/bugs/bug-$a-*.t)
+ match=0
+ ;;
+ esac
+ done
+ if [ "${DONE[$(dirname $t)]}" != "" ] ; then
+ # Parentdir is already matched
+ match=1
+ if [ -d $t ] ; then
+ # Ignore subdirectory as well
+ DONE[$t]=$t
+ fi
+ elif [ $match -eq 0 -a -d $t ] ; then
+ # Make sure children of this matched directory will be ignored
+ DONE[$t]=$t
+ elif [[ -f $t && ! $t =~ .*\.t ]] ; then
+ # Ignore files not ending in .t
+ match=1
+ fi
+ return $match
+ }
+ RES=0
+ for t in $(find ${regression_testsdir}/tests | LC_COLLATE=C sort) ; do
+ if match $t "$@" ; then
+ if [ -d $t ] ; then
+ echo "Running tests in directory $t"
+ prove -rf --timer $t
+ elif [ -f $t ] ; then
+ echo "Running tests in file $t"
+ prove -f --timer $t
+ fi
+ TMP_RES=$?
+ if [ ${TMP_RES} -ne 0 ] ; then
+ RES=${TMP_RES}
+ FAILED="$FAILED $t"
+ fi
+ fi
+ done
+ if [ ${RES} -ne 0 ] ; then
+ echo "Failed tests ${FAILED}"
+ fi
+ return ${RES}
+}
+
function main()
{
if [ $# -lt 1 ]; then
echo "Running all the regression test cases"
prove -rf --timer ${regression_testsdir}/tests;
else
- ## TODO
- echo "Running single regression test.."
- echo "WARNING: yet to be implemented.. exiting safely"
- exit 0
- #export DEBUG=1;
- #echo "Automatically setting up DEBUG=1 for this test $1";
+ run_tests "$@"
fi
}