about summary refs log tree commit diff
path: root/Test
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2014-02-13 08:23:32 -0800
committerBarton E. Schaefer <schaefer@zsh.org>2014-02-13 08:23:32 -0800
commit5c89c4ca9c1303add65b1927b94d95c72be2e096 (patch)
treefe66904d3cfa5df9c03d3af0be9c5b6b3c4f7cee /Test
parentba58bfe4bfa16e756c8f38cfa0e992ad38b00856 (diff)
downloadzsh-5c89c4ca9c1303add65b1927b94d95c72be2e096.tar.gz
zsh-5c89c4ca9c1303add65b1927b94d95c72be2e096.tar.xz
zsh-5c89c4ca9c1303add65b1927b94d95c72be2e096.zip
32377: change keybindings and PTY control for vi-mode tests to make them more reliable
Diffstat (limited to 'Test')
-rw-r--r--Test/comptest36
1 files changed, 28 insertions, 8 deletions
diff --git a/Test/comptest b/Test/comptest
index f1c5af01f..4a23e8937 100644
--- a/Test/comptest
+++ b/Test/comptest
@@ -69,12 +69,15 @@ comp-finish () {
   zle -R
 }
 zle-finish () {
-  print -lr "<WIDGET><finish>" "BUFFER: $BUFFER" "CURSOR: $CURSOR"
-  (( region_active )) && print -lr "MARK: $MARK"
-  zle -K main
+  local buffer="$BUFFER" cursor="$CURSOR" mark="$MARK"
+  (( region_active)) || unset mark
+  BUFFER=""
+  zle -I
   zle clear-screen
-  zle send-break
-  zle -R
+  zle redisplay
+  print -lr "<WIDGET><finish>" "BUFFER: $buffer" "CURSOR: $cursor"
+  (( $+mark )) && print -lr "MARK: $mark"
+  zle accept-line
 }
 zle -N expand-or-complete-with-report
 zle -N list-choices-with-report
@@ -83,30 +86,45 @@ zle -N zle-finish
 bindkey "^I" expand-or-complete-with-report
 bindkey "^D" list-choices-with-report
 bindkey "^Z" comp-finish
-bindkey "^M" zle-finish
-bindkey -a "^M" zle-finish
+bindkey "^X" zle-finish
+bindkey -a "^X" zle-finish
 '
 }
 
+zpty_flush() {
+  local junk
+  if zpty -r -t zsh junk \*; then
+    (( ZTST_verbose > 2 )) && print -n -u $ZTST_fd "$*: ${(V)junk}"
+    while zpty -r -t zsh junk \* ; do
+      (( ZTST_verbose > 2 )) && print -n -u $ZTST_fd "${(V)junk}"
+    done
+    (( ZTST_verobse > 2 )) && print -u $ZTST_fd ''
+  fi
+}
+
 comptesteval () {
   local tmp=/tmp/comptest.$$
 
   print -lr - "$@" > $tmp
+  zpty_flush Before comptesteval
   zpty -w zsh ". $tmp"
   zpty -r -m zsh log_eval "*<PROMPT>*" || {
     print "prompt hasn't appeared."
     return 1
   }
+  zpty_flush After comptesteval
   rm $tmp
 }
 
 comptest () {
   input="$*"
+  zpty_flush Before comptest
   zpty -n -w zsh "$input"$'\C-Z'
   zpty -r -m zsh log "*<WIDGET><finish>*<PROMPT>*" || {
     print "failed to invoke finish widget."
     return 1
   }
+  zpty_flush After comptest
 
   logs=(${(s:<WIDGET>:)log})
   shift logs
@@ -136,10 +154,12 @@ comptest () {
 
 zletest () {
   input="$*"
-  zpty -n -w zsh "$input"$'\C-M'
+  zpty_flush Before zletest
+  zpty -n -w zsh "$input"$'\C-X'
   zpty -r -m zsh log "*<WIDGET><finish>*<PROMPT>*" || {
     print "failed to invoke finish widget."
     return 1
   }
+  zpty_flush After zletest
   print -lr "${(@)${(ps:\r\n:)log##*<WIDGET><finish>}[1,-2]}"
 }