summaryrefslogtreecommitdiff
path: root/tests/testwrapper.sh
diff options
context:
space:
mode:
authorManoj Srivastava <srivasta@debian.org>2016-01-22 13:36:58 -0800
committerManoj Srivastava <srivasta@debian.org>2016-01-22 13:36:58 -0800
commit426e91fa66c2a2341d46f977ee351bd24ef3331c (patch)
treeb4d506125335b5e5d748ac284b7239e10df96d21 /tests/testwrapper.sh
parent26bb2525c89ecda0b0bc7b597ec8d1b792fc8662 (diff)
parent83d5d1695a2ab1d69ea4d8e7df27146c644876fc (diff)
Merge tag 'v2.6.0' into upstream
flex v2.6.0 release Signed-off-by: Manoj Srivastava <srivasta@debian.org> # gpg: Signature made Sat 05 Dec 2015 11:42:31 AM PST using RSA key ID 4F8BC9A4 # gpg: requesting key 4F8BC9A4 from hkp server pool.sks-keyservers.net # gpg: no valid OpenPGP data found. # gpg: Total number processed: 0 # gpg: keyserver communications error: key not found # gpg: keyserver communications error: bad public key # gpg: Can't check signature: public key not found # Conflicts: # Makefile.am # NEWS # autogen.sh # configure.ac # doc/Makefile.am # doc/flex.texi # examples/fastwc/mywc.c # lib/Makefile.am # lib/malloc.c # lib/realloc.c # po/POTFILES.in # po/ca.po # po/da.po # po/de.po # po/eo.po # po/es.po # po/fi.po # po/fr.po # po/ga.po # po/hr.po # po/ko.po # po/nl.po # po/pl.po # po/pt_BR.po # po/ro.po # po/ru.po # po/sr.po # po/sv.po # po/tr.po # po/vi.po # po/zh_CN.po # po/zh_TW.po # tests/Makefile.am # tests/README
Diffstat (limited to 'tests/testwrapper.sh')
-rwxr-xr-xtests/testwrapper.sh53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/testwrapper.sh b/tests/testwrapper.sh
new file mode 100755
index 0000000..30127b5
--- /dev/null
+++ b/tests/testwrapper.sh
@@ -0,0 +1,53 @@
+#!/bin/bash -vx
+set -euo pipefail
+
+# testwrapper.sh: run a flex test, typically called by a Makefile
+
+# Each test will exercise some feature or aspect of flex. Run the test with any input it may need.
+
+INPUT_DIRECTORY=""
+INPUT_NAME=""
+INPUT_COUNT=0
+USE_REDIRECT=0
+DO_COMPARISON=0
+
+while getopts :d:i:rt1 OPTION ; do
+ case $OPTION in
+ d) INPUT_DIRECTORY=$OPTARG ;;
+ i)
+ if [ "$INPUT_NAME" == "" ] ; then
+ INPUT_NAME="$OPTARG"
+ else
+ INPUT_NAME="$INPUT_NAME $OPTARG"
+ fi
+ INPUT_COUNT=$(($INPUT_COUNT+1))
+ ;;
+ r) USE_REDIRECT=1 ;;
+ t) USE_TABLES=1 ;;
+ 1) DO_COMPARISON=1 ;;
+ esac
+ done
+
+TESTNAME="${!OPTIND}"
+
+INPUT_NAME=${INPUT_NAME:-`basename $TESTNAME`.txt}
+
+if [ "$DO_COMPARISON" -eq "1" ] ; then
+ test `$TESTNAME 1 < $INPUT_DIRECTORY/$INPUT_NAME` -eq `$TESTNAME < $INPUT_DIRECTORY/$INPUT_NAME`
+ exit $?
+ fi
+
+if [ $INPUT_COUNT -gt 1 ] ; then
+ $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME}.tables} ${INPUT_NAME}
+ exit $?
+ fi
+
+if [ -f ${INPUT_DIRECTORY}/${INPUT_NAME} ] ; then
+ if [ $USE_REDIRECT == 1 ] ; then
+ $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME}.tables} < $INPUT_DIRECTORY/$INPUT_NAME
+ else
+ $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME}.tables} $INPUT_DIRECTORY/$INPUT_NAME
+ fi
+else
+ $TESTNAME
+fi