summaryrefslogtreecommitdiff
path: root/tests/testwrapper.sh
diff options
context:
space:
mode:
authorExplorer09 <explorer09@gmail.com>2017-01-02 09:03:12 +0800
committerWill Estes <westes575@gmail.com>2017-01-17 21:10:16 -0500
commitbcf7a07369f3d407378c3980f5411459f07a111f (patch)
tree3f45bbd6f41abd8b65533bc0266759741866fb87 /tests/testwrapper.sh
parent8c8691c3fdb327eb45d5ee831da62e7433563004 (diff)
test: Remove test scripts bashisms.
They now all work under a POSIX compliant sh. Specifically, 'dash' can now be used for running "make check" tests. Note that none of these scripts has ever been using a pipe, so `set -o pipefail` is unnecessary and removed.
Diffstat (limited to 'tests/testwrapper.sh')
-rwxr-xr-xtests/testwrapper.sh21
1 files changed, 12 insertions, 9 deletions
diff --git a/tests/testwrapper.sh b/tests/testwrapper.sh
index 188d479..6a7e666 100755
--- a/tests/testwrapper.sh
+++ b/tests/testwrapper.sh
@@ -1,9 +1,11 @@
-#!/bin/bash -vx
-set -euo pipefail
+#!/bin/sh
+set -vx
+set -euvx
# 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.
+# Each test will exercise some feature or aspect of flex. Run the test with any
+# input it may need.
INPUT_DIRECTORY=""
INPUT_NAME=""
@@ -15,7 +17,7 @@ while getopts :d:i:rt1 OPTION ; do
case $OPTION in
d) INPUT_DIRECTORY=$OPTARG ;;
i)
- if [ "$INPUT_NAME" == "" ] ; then
+ if [ "$INPUT_NAME" = "" ] ; then
INPUT_NAME="$OPTARG"
else
INPUT_NAME="$INPUT_NAME $OPTARG"
@@ -26,13 +28,14 @@ while getopts :d:i:rt1 OPTION ; do
t) USE_TABLES=1 ;;
1) DO_COMPARISON=1 ;;
esac
- done
+done
-TESTNAME="${!OPTIND}"
+shift $(($OPTIND-1))
+TESTNAME=$1
-INPUT_NAME=${INPUT_NAME:-$INPUT_DIRECTORY/`basename ${TESTNAME%.exe}`.txt}
+INPUT_NAME=${INPUT_NAME:-$INPUT_DIRECTORY/`basename "${TESTNAME%.exe}"`.txt}
-if [ "$DO_COMPARISON" -eq "1" ] ; then
+if [ $DO_COMPARISON = 1 ] ; then
TEST_OUTPUT=`$TESTNAME < $INPUT_NAME`
REF_OUTPUT=`$TESTNAME 1 < $INPUT_NAME`
test "$TEST_OUTPUT" -eq "$REF_OUTPUT"
@@ -45,7 +48,7 @@ if [ $INPUT_COUNT -gt 1 ] ; then
fi
if [ -f ${INPUT_NAME} ] ; then
- if [ $USE_REDIRECT == 1 ] ; then
+ if [ $USE_REDIRECT = 1 ] ; then
$TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables} < $INPUT_NAME
else
$TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables} $INPUT_NAME