[Bash-completion-commits] [SCM] bash-completion branch, expect-fixes, updated. 1b200eca213963e2e85013c7a80e92fda910034e
Crestez Dan Leonard
cdleonard at gmail.com
Thu Mar 18 04:16:52 UTC 2010
The following commit has been merged in the expect-fixes branch:
commit 2ca9db0a60ff83e7d3544c5c6ed78f0dcee5db20
Merge: 4743f397597cc093421ade2b4f24d5a2bd35a0b4 0f49bb1e3ca0074e81f106184854efd30dac2b8a
Author: Crestez Dan Leonard <cdleonard at gmail.com>
Date: Sun Mar 7 19:10:31 2010 +0200
Merge commit '0f49' into expect-fixes
diff --combined test/lib/library.exp
index a294cf6,f582922..97bede3
--- a/test/lib/library.exp
+++ b/test/lib/library.exp
@@@ -618,9 -618,9 +618,9 @@@ proc match_items {items test {prompt /@
}; # for
if {[llength $items] == 1} {
expect {
- -re "^$expected\r\n$" { set result true }
+ -re "^$expected\r\n" { set result true }
# NOTE: The optional space ( ?) depends on whether -o nospace is active
- -re "^$expected ?$" { set result true }
+ -re "^$expected ?" { set result true }
-re "^$prompt$" {set result false; break }
"\r\n" { set result false; break }
default { set result false; break }
@@@ -829,42 -829,65 +829,84 @@@ 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
+ }
+ global OPT_TIMEOUT
+ if {[info exists OPT_TIMEOUT]} {
+ global timeout
+ verbose "Changing default expect timeout from $timeout to $OPT_TIMEOUT"
+ set timeout $OPT_TIMEOUT
+ }
+ }
+
+
# Interrupt completion and sync with prompt.
# Send signals QUIT & INT.
+#
+# This will match everything up to an including the new prompt.
+#
# @param string $prompt (optional) Bash prompt. Default is "/@"
proc sync_after_int {{prompt /@}} {
+
+ # expect_after will access the $test variable.
set test "Sync after INT"
- sleep .1
- send \031\003; # QUIT/INT
- # Wait to allow bash to become ready
- # See also: http://lists.alioth.debian.org/pipermail/bash-completion-devel/
- # 2010-February/002566.html
- sleep .1
- # NOTE: 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 ".*$prompt$"
+
+ # 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$"
+
+ # 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$"
}
--
bash-completion
More information about the Bash-completion-commits
mailing list