2009-12-24 09:43:24 +01:00
|
|
|
#!/bin/bash
|
2010-02-20 22:53:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
# Print some helpful messages.
|
|
|
|
usage() {
|
|
|
|
echo "Run bash-completion tests"
|
|
|
|
echo
|
|
|
|
echo "The 'tool' is determined automatically from filenames."
|
|
|
|
echo "Unrecognized options are passed through to dejagnu by default."
|
|
|
|
echo
|
|
|
|
echo "Interesting options:"
|
|
|
|
echo " --tool_exec= Test against a different bash executable."
|
|
|
|
echo " --debug Create a dbg.log in the test directory with detailed expect match information."
|
2010-02-21 00:53:18 +02:00
|
|
|
echo " --timeout Change expect timeout from the default of 10 seconds."
|
2010-02-20 22:53:30 +02:00
|
|
|
echo " --debug-xtrace Create an xtrace.log in the test directory with set -x output. Requires bash 4.1."
|
|
|
|
echo
|
|
|
|
echo "Example run: ./run unit/_get_cword.exp unit/compgen.exp"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Try to set the tool variable; or fail if trying to set different values.
|
|
|
|
set_tool() {
|
|
|
|
if [[ $tool ]]; then
|
|
|
|
if [[ $tool != $1 ]]; then
|
|
|
|
echo "Tool spec mismatch ('$tool' and '$1'). See --usage."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
tool=$1
|
|
|
|
fi
|
2009-12-24 09:43:24 +01:00
|
|
|
}
|
|
|
|
|
2010-02-20 22:53:30 +02:00
|
|
|
|
2010-04-21 23:19:34 +03:00
|
|
|
cd "$(dirname "${BASH_SOURCE[0]}")"
|
2010-02-20 22:53:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
# Loop over the arguments.
|
2009-12-24 09:43:24 +01:00
|
|
|
args=()
|
2010-02-20 22:53:30 +02:00
|
|
|
while [[ $# > 0 ]]; do
|
|
|
|
case "$1" in
|
|
|
|
--help|--usage) usage; exit 1;;
|
|
|
|
--debug-xtrace) args+=(OPT_BASH_XTRACE=1);;
|
2010-02-21 00:53:18 +02:00
|
|
|
--timeout) shift; timeout=$1;;
|
|
|
|
--timeout=*) timeout=${1/--timeout=};;
|
2010-02-20 22:53:30 +02:00
|
|
|
--tool=*) set_tool "${1#/--tool=}";;
|
|
|
|
--tool) shift; set_tool "$1";;
|
2010-06-18 16:59:38 +02:00
|
|
|
completion/*.exp|*/completion/*.exp|unit/*.exp|*/unit/*.exp)
|
2010-02-20 22:53:30 +02:00
|
|
|
arg=${1%/*}
|
|
|
|
set_tool "${arg##*/}"
|
|
|
|
args+=("${1##*/}")
|
|
|
|
;;
|
|
|
|
*) args+=("$1")
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2009-12-24 09:43:24 +01:00
|
|
|
|
2010-02-21 00:53:18 +02:00
|
|
|
[[ -n $timeout ]] && args+=("OPT_TIMEOUT=$timeout")
|
2010-02-20 22:53:30 +02:00
|
|
|
[[ -z $tool ]] && { echo "Must specify tool somehow"; exit 1; }
|
|
|
|
|
2010-04-21 23:34:27 +03:00
|
|
|
exec runtest --outdir log --tool $tool "${args[@]}"
|