diff options
author | Explorer09 <explorer09@gmail.com> | 2017-01-02 09:03:12 +0800 |
---|---|---|
committer | Will Estes <westes575@gmail.com> | 2017-01-17 21:10:16 -0500 |
commit | bcf7a07369f3d407378c3980f5411459f07a111f (patch) | |
tree | 3f45bbd6f41abd8b65533bc0266759741866fb87 /tests | |
parent | 8c8691c3fdb327eb45d5ee831da62e7433563004 (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')
-rwxr-xr-x | tests/options.cn | 2 | ||||
-rwxr-xr-x | tests/tableopts.sh | 15 | ||||
-rwxr-xr-x | tests/testwrapper-direct.sh | 15 | ||||
-rwxr-xr-x | tests/testwrapper.sh | 21 |
4 files changed, 31 insertions, 22 deletions
diff --git a/tests/options.cn b/tests/options.cn index 2f592e9..5af60ea 100755 --- a/tests/options.cn +++ b/tests/options.cn @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Test that flex handles the grouped noop options -c and -n properly. diff --git a/tests/tableopts.sh b/tests/tableopts.sh index 63a36d3..52f3ac1 100755 --- a/tests/tableopts.sh +++ b/tests/tableopts.sh @@ -1,12 +1,15 @@ -#!/bin/bash -set -euo pipefail -IFS=$'\n\t' +#!/bin/sh +set -eu +# IFS=$'\n\t' +IFS=' +'' ' # This script is present to generate the automake _SOURCES variables # for the tableopts_* tests. It also generates the linking rules for # each test since automake isn't able to handle the pattern rules that # would be natural to use. Output is written to standard output for -# inclusion in a Makefile.am, typically by redirecting the output and then an automake include directive. +# inclusion in a Makefile.am, typically by redirecting the output and +# then an automake include directive. TABLEOPTS_TESTS="" tableopts_tables="" @@ -17,12 +20,12 @@ for kind in opt ser ver ; do testname=tableopts_${kind}_${threading}${opt}.${kind} if [ "${TABLEOPTS_TESTS}" = "" ] ;then TABLEOPTS_TESTS=${testname} - if [ "$kind" = "ser" -o "$kind" = "ver" ] ; then + if [ "$kind" = "ser" ] || [ "$kind" = "ver" ] ; then tableopts_tables=${testname}.tables fi else TABLEOPTS_TESTS="${TABLEOPTS_TESTS} ${testname}" - if [ "$kind" = "ser" -o "$kind" = "ver" ] ; then + if [ "$kind" = "ser" ] || [ "$kind" = "ver" ] ; then tableopts_tables="${tableopts_tables} ${testname}.tables" fi fi diff --git a/tests/testwrapper-direct.sh b/tests/testwrapper-direct.sh index e0e7fd9..589ad33 100755 --- a/tests/testwrapper-direct.sh +++ b/tests/testwrapper-direct.sh @@ -1,17 +1,20 @@ -#!/bin/bash -vx -set -euo pipefail +#!/bin/sh +set -vx +set -euvx -# testwrapper-direct.sh: run some specialized flex tests that care where they're run from. +# testwrapper-direct.sh: run some specialized flex tests that care where +# they're run from. while getopts :b:s: OPTION ; do case $OPTION in - b) BINARY_DIR=$OPTARG ;; + b) BINARY_DIR=$OPTARG ;; s) SOURCE_DIR=$OPTARG ;; esac done -TESTNAME="${!OPTIND}" +shift $(($OPTIND-1)) +TESTNAME=$1 -INPUT_NAME=`basename ${TESTNAME%.exe}`.txt +INPUT_NAME=`basename "${TESTNAME%.exe}"`.txt cd ${SOURCE_DIR} && ${BINARY_DIR}/${TESTNAME} ${INPUT_NAME} 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 |