about summary refs log tree commit diff
path: root/Test/comptest
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2013-02-12 10:55:32 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2013-02-12 10:55:32 +0000
commitb6544d1ef3312cc133da648d290d2ec2866c277d (patch)
tree4c20a1edb307b3dd687d1941ef3cf48a13c47dbd /Test/comptest
parent0a8c28b3d655b52bc600e052db1da43bf4a98bae (diff)
downloadzsh-b6544d1ef3312cc133da648d290d2ec2866c277d.tar.gz
zsh-b6544d1ef3312cc133da648d290d2ec2866c277d.tar.xz
zsh-b6544d1ef3312cc133da648d290d2ec2866c277d.zip
31041: add support for testing line editor widgets from the test suite
Diffstat (limited to 'Test/comptest')
-rw-r--r--Test/comptest33
1 files changed, 28 insertions, 5 deletions
diff --git a/Test/comptest b/Test/comptest
index 14938a7cd..5577209da 100644
--- a/Test/comptest
+++ b/Test/comptest
@@ -8,10 +8,12 @@ comptestinit () {
   zmodload -i zsh/zpty || return $?
 
   comptest_zsh=${ZSH:-zsh}
+  comptest_keymap=e
 
-  while getopts z: opt; do
+  while getopts vz: opt; do
     case $opt in
       z) comptest_zsh="$OPTARG";;
+      v) comptest_keymap="v";;
     esac
   done
   (( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
@@ -30,11 +32,11 @@ comptestinit () {
 "export ZDOTDIR=$ZTST_testdir" \
 "module_path=( $module_path )" \
 "fpath=( $fpath )" \
+"bindkey -$comptest_keymap" \
 'LISTMAX=10000000
 TERM=vt100
 stty columns 80 rows 24
 setopt zle
-bindkey -e
 autoload -U compinit
 compinit -u
 zstyle ":completion:*:default" list-colors "no=<NO>" "fi=<FI>" "di=<DI>" "ln=<LN>" "pi=<PI>" "so=<SO>" "bd=<BD>" "cd=<CD>" "ex=<EX>" "mi=<MI>" "tc=<TC>" "sp=<SP>" "lc=<LC>" "ec=<EC>\n" "rc=<RC>"
@@ -60,18 +62,29 @@ list-choices-with-report () {
   zle clear-screen
   zle -R
 }
-finish () {
+comp-finish () {
   print "<WIDGET><finish>"
   zle kill-whole-line
   zle clear-screen
   zle -R
 }
+zle-finish () {
+  print -lr "<WIDGET><finish>" "BUFFER: $BUFFER" "CURSOR: $CURSOR"
+  (( region_active )) && print -lr "MARK: $MARK"
+  zle -K main
+  zle kill-whole-line
+  zle clear-screen
+  zle -R
+}
 zle -N expand-or-complete-with-report
 zle -N list-choices-with-report
-zle -N finish
+zle -N comp-finish
+zle -N zle-finish
 bindkey "^I" expand-or-complete-with-report
 bindkey "^D" list-choices-with-report
-bindkey "^Z" finish
+bindkey "^Z" comp-finish
+bindkey "^M" zle-finish
+bindkey -a "^M" zle-finish
 '
 }
 
@@ -120,3 +133,13 @@ comptest () {
     done
   done
 }
+
+zletest () {
+  input="$*"
+  zpty -n -w zsh "$input"$'\C-M'
+  zpty -r -m zsh log "*<WIDGET><finish>*<PROMPT>*" || {
+    print "failed to invoke finish widget."
+    return 1
+  }
+  print -lr "${(@)${(ps:\r\n:)log##*<WIDGET><finish>}[1,-2]}"
+}