summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCrestez Dan Leonard <cdleonard@gmail.com>2010-03-18 05:50:01 +0200
committerCrestez Dan Leonard <cdleonard@gmail.com>2010-03-18 05:50:01 +0200
commit153f65a3ca261723f96b41006a48260c5f80db6c (patch)
tree72fd98ce2a04f144aef738399d226a13b33ca0b6
parent2ca9db0a60ff83e7d3544c5c6ed78f0dcee5db20 (diff)
downloadbash-completion-153f65a3ca261723f96b41006a48260c5f80db6c.tar.gz
(testsuite) Make fast synchronisation optional and disabled by default
-rw-r--r--test/lib/library.exp58
-rwxr-xr-xtest/run4
2 files changed, 42 insertions, 20 deletions
diff --git a/test/lib/library.exp b/test/lib/library.exp
index 97bede3b..1aebfa3e 100644
--- a/test/lib/library.exp
+++ b/test/lib/library.exp
@@ -879,34 +879,52 @@ proc start_interactive_test {} {
# @param string $prompt (optional) Bash prompt. Default is "/@"
proc sync_after_int {{prompt /@}} {
+ # Check for fast mode
+ global OPT_FAST_SYNC
+ set opt_fast 0
+ if {[info exists OPT_FAST_SYNC]} {
+ set opt_fast $OPT_FAST_SYNC
+ }
+
# expect_after will access the $test variable.
set test "Sync after INT"
# We synchronise in two steps.
-
- # First we send a text we hope is unique and swallow everything before it.
- set synctext "sync[expr int(rand() * 1000)]"
-
- # \005 is ^E; move to end of the line in emacs mode. This is required
- # because some tests use cmdline features and leave the 'cursor' in the
- # middle of a line
- send "\005$synctext"
-
- # Regexp `.*' causes `expect' to discard previous unknown output.
- # This is necessary if a completion doesn't match expectations.
- # For instance with `filetype_xspec' completion (e.g. `kdvi') if
- # one expects `.txt' as a completion (wrong, because it isn't
- # there), the unmatched completions need to be cleaned up.
- expect -re ".*$synctext$"
+ if {$opt_fast} {
+ # First we send a text we hope is unique and swallow everything before it.
+ set synctext "sync[expr int(rand() * 1000)]"
+
+ # \005 is ^E; move to end of the line in emacs mode. This is required
+ # because some tests use cmdline features and leave the 'cursor' in the
+ # middle of a line
+ send "\005$synctext"
+
+ # Regexp `.*' causes `expect' to discard previous unknown output.
+ # This is necessary if a completion doesn't match expectations.
+ # For instance with `filetype_xspec' completion (e.g. `kdvi') if
+ # one expects `.txt' as a completion (wrong, because it isn't
+ # there), the unmatched completions need to be cleaned up.
+ expect -re ".*$synctext$"
+ } else {
+ # Slow alternative is to sleep before sending an intrerrupt
+ sleep 0.1
+ }
# Then we send QUIT/INT and match the new prompt that shows up.
send \031\003;
- # Bash versions >4 will echo a ^C by default. This can be disabled in
- # inputrc starting from bash 4.1. This is not enough; we need to run tests
- # against bash-4.0 as well.
- # See http://www.mail-archive.com/bug-bash@gnu.org/msg07038.html
- expect -re "^(\\^C)?\\r\\n$prompt$"
+ if {$opt_fast} {
+ # Bash versions >4 will echo a ^C by default. This can be disabled in
+ # inputrc starting from bash 4.1. This is not enough; we need to run tests
+ # against bash-4.0 as well.
+ # See http://www.mail-archive.com/bug-bash@gnu.org/msg07038.html
+ expect -re "^(\\^C)?\\r\\n$prompt$"
+ } else {
+ # Slow alternative is to sleep and hope we don't match the first of
+ # two prompts
+ sleep 0.1
+ expect -re ".*$prompt$"
+ }
}
diff --git a/test/run b/test/run
index cdb1145a..ff51c541 100755
--- a/test/run
+++ b/test/run
@@ -8,11 +8,14 @@ usage() {
echo "The 'tool' is determined automatically from filenames."
echo "Unrecognized options are passed through to dejagnu by default."
echo
+ echo "If you're impatient you can try --timeout 1 --fast-sync, but beware of strange failures from race conditions"
+ 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 " --timeout Change expect timeout from the default of 10 seconds."
echo " --debug-xtrace Create an xtrace.log in the test directory with set -x output. Requires bash 4.1."
+ echo " --fast-sync Remove sleep statements from the sync_after_int function"
echo
echo "Example run: ./run unit/_get_cword.exp unit/compgen.exp"
}
@@ -40,6 +43,7 @@ while [[ $# > 0 ]]; do
case "$1" in
--help|--usage) usage; exit 1;;
--debug-xtrace) args+=(OPT_BASH_XTRACE=1);;
+ --fast-sync) args+=(OPT_FAST_SYNC=1);;
--timeout) shift; timeout=$1;;
--timeout=*) timeout=${1/--timeout=};;
--tool=*) set_tool "${1#/--tool=}";;