[Bash-completion-commits] [SCM] bash-completion branch, expect-fixes, updated. 1b200eca213963e2e85013c7a80e92fda910034e

Crestez Dan Leonard cdleonard at gmail.com
Thu Mar 18 04:16:53 UTC 2010


The following commit has been merged in the expect-fixes branch:
commit 153f65a3ca261723f96b41006a48260c5f80db6c
Author: Crestez Dan Leonard <cdleonard at gmail.com>
Date:   Thu Mar 18 05:50:01 2010 +0200

    (testsuite) Make fast synchronisation optional and disabled by default

diff --git a/test/lib/library.exp b/test/lib/library.exp
index 97bede3..1aebfa3 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 cdb1145..ff51c54 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=}";;

-- 
bash-completion



More information about the Bash-completion-commits mailing list