(testsuite) Add a --debug-xtrace option to run.
Cleanup test/run scripts and add a --debug-xtrace option.
This commit is contained in:
parent
7ef06fb2df
commit
f9177e5286
3
CHANGES
3
CHANGES
@ -72,6 +72,9 @@ bash-completion (2.x)
|
||||
* Fix chown test crashing on systems with no root group (Alioth: #312306).
|
||||
* Fixed tests when BASH_COMPLETION or TESTDIR contain spaces.
|
||||
* Fix mount handling of escapes (Alioth: #311410, Launchpad: #219971).
|
||||
* Cleanup scripts to run tests. Make runUnit and runCompletion use test/run.
|
||||
Make it possible to run tests from any directory.
|
||||
* Add a --debug-xtrace option to test/run using BASH_XTRACEFD from bash-4.1.
|
||||
|
||||
[ Raphaël Droz ]
|
||||
* Add xsltproc completion (Alioth: #311843).
|
||||
|
1
test/.gitignore
vendored
1
test/.gitignore
vendored
@ -1 +1,2 @@
|
||||
dbg.log
|
||||
xtrace.log
|
||||
|
@ -2,16 +2,13 @@ source ${srcdir}/lib/library.exp
|
||||
|
||||
|
||||
proc completion_exit {} {
|
||||
# Exit bash
|
||||
send "\rexit\r"
|
||||
}; # completion_exit()
|
||||
}
|
||||
|
||||
|
||||
proc completion_start {} {
|
||||
start_bash
|
||||
source_bash_completion
|
||||
init_tcl_bash_globals
|
||||
}; # completion_start()
|
||||
start_interactive_test
|
||||
}
|
||||
|
||||
|
||||
proc completion_version {} {
|
||||
|
@ -829,6 +829,42 @@ proc start_bash {} {
|
||||
}; # start_bash()
|
||||
|
||||
|
||||
# Redirect xtrace output to a file.
|
||||
#
|
||||
# 'set -x' can be very useful for debugging but by default it writes to
|
||||
# stderr. Bash 4.1 has a feature to redirect this output to a random FD.
|
||||
#
|
||||
# This function uses file descriptor 6. This will break if any completion
|
||||
# tries to use the same descriptor.
|
||||
proc init_bash_xtrace {{fname xtrace.log}} {
|
||||
global BASH_VERSINFO
|
||||
if {([lindex $BASH_VERSINFO 0] == 4 && [lindex $BASH_VERSINFO 1] < 1) ||
|
||||
[lindex $BASH_VERSINFO 0] < 4} {
|
||||
note "BASH_XTRACEFD not available in this version; no xtrace.log"
|
||||
return
|
||||
}
|
||||
verbose "Enabling bash xtrace output to '$fname'"
|
||||
assert_bash_exec "exec 6>'$fname'"
|
||||
assert_bash_exec "BASH_XTRACEFD=6"
|
||||
assert_bash_exec "set -o xtrace"
|
||||
}
|
||||
|
||||
|
||||
# Setup test environment
|
||||
#
|
||||
# Common initialization for unit and completion tests.
|
||||
proc start_interactive_test {} {
|
||||
start_bash
|
||||
source_bash_completion
|
||||
init_tcl_bash_globals
|
||||
|
||||
global OPT_BASH_XTRACE
|
||||
if {[info exists OPT_BASH_XTRACE]} {
|
||||
init_bash_xtrace
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Interrupt completion and sync with prompt.
|
||||
# Send signals QUIT & INT.
|
||||
# @param string $prompt (optional) Bash prompt. Default is "/@"
|
||||
|
@ -2,16 +2,14 @@ source lib/library.exp
|
||||
|
||||
|
||||
proc unit_exit {} {
|
||||
# Exit bash
|
||||
# Exit bash
|
||||
send "\rexit\r"
|
||||
}; # unit_exit()
|
||||
}
|
||||
|
||||
|
||||
proc unit_start {} {
|
||||
start_bash
|
||||
source_bash_completion
|
||||
init_tcl_bash_globals
|
||||
}; # unit_start()
|
||||
start_interactive_test
|
||||
}
|
||||
|
||||
|
||||
proc unit_version {} {
|
||||
|
75
test/run
75
test/run
@ -1,31 +1,56 @@
|
||||
#!/bin/bash
|
||||
# Run test of specified tool.
|
||||
# The first directory of the first file (first argument ending with .exp) is
|
||||
# used as the `tool' specification.
|
||||
# Usage: ./run [FILE]...
|
||||
# Example run: ./run unit/_get_cword.exp unit/compgen.exp
|
||||
|
||||
|
||||
# Process arguments
|
||||
# @param $1 Name of variable to return `tool' name
|
||||
# @param $2 Name of variable to return processed arguments
|
||||
# @param $@ Arguments to process
|
||||
process_args() {
|
||||
local arg
|
||||
for arg in "${@:3}"; do
|
||||
case "$arg" in
|
||||
completion/*.exp|unit/*.exp)
|
||||
[[ ${!1} ]] || printf -v $1 "${arg%%/*}"
|
||||
eval $2[\${#$2[@]}]=\""${arg#*/}"\"
|
||||
;;
|
||||
*)
|
||||
eval $2[\${#$2[@]}]=\""$arg"\"
|
||||
esac
|
||||
done
|
||||
# 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."
|
||||
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"
|
||||
}
|
||||
|
||||
args=()
|
||||
process_args tool args "$@"
|
||||
runtest --outdir log --tool $tool "${args[@]}"
|
||||
|
||||
unset -v args tool
|
||||
# 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
|
||||
}
|
||||
|
||||
|
||||
cd "${BASH_SOURCE[0]%/*}"
|
||||
|
||||
|
||||
# Loop over the arguments.
|
||||
args=()
|
||||
while [[ $# > 0 ]]; do
|
||||
case "$1" in
|
||||
--help|--usage) usage; exit 1;;
|
||||
--debug-xtrace) args+=(OPT_BASH_XTRACE=1);;
|
||||
--tool=*) set_tool "${1#/--tool=}";;
|
||||
--tool) shift; set_tool "$1";;
|
||||
*/completion/*.exp|*/unit/*.exp)
|
||||
arg=${1%/*}
|
||||
set_tool "${arg##*/}"
|
||||
args+=("${1##*/}")
|
||||
;;
|
||||
*) args+=("$1")
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
[[ -z $tool ]] && { echo "Must specify tool somehow"; exit 1; }
|
||||
|
||||
runtest --outdir log --tool $tool "${args[@]}"
|
||||
|
@ -4,4 +4,4 @@
|
||||
# isn't initialized at that point (i.e. output of `expect' is shown on
|
||||
# stdout - `open_logs' hasn't run yet?). And running code from a library
|
||||
# file isn't probably a good idea either.
|
||||
runtest --outdir log --tool completion $*
|
||||
"${BASH_SOURCE[0]%/*}/run" --tool completion $*
|
||||
|
@ -4,4 +4,4 @@
|
||||
# isn't initialized at that point (i.e. output of `expect' is shown on
|
||||
# stdout - `open_logs' hasn't run yet?). And running code from a library
|
||||
# file isn't probably a good idea either.
|
||||
runtest --outdir log --tool unit $*
|
||||
"${BASH_SOURCE[0]%/*}/run" --tool unit $*
|
||||
|
Loading…
x
Reference in New Issue
Block a user