From b6544d1ef3312cc133da648d290d2ec2866c277d Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Tue, 12 Feb 2013 10:55:32 +0000 Subject: 31041: add support for testing line editor widgets from the test suite --- Test/X02zlevi.ztst | 20 ++++++++++++++++++++ Test/comptest | 33 ++++++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 Test/X02zlevi.ztst (limited to 'Test') diff --git a/Test/X02zlevi.ztst b/Test/X02zlevi.ztst new file mode 100644 index 000000000..d4a125f21 --- /dev/null +++ b/Test/X02zlevi.ztst @@ -0,0 +1,20 @@ +# Tests of the vi mode of ZLE + +%prep + if ( zmodload -i zsh/zpty ) >/dev/null 2>&1; then + . $ZTST_srcdir/comptest + comptestinit -v -z $ZTST_testdir/../Src/zsh + else + ZTST_unimplemented="the zsh/zpty module is not available" + fi + +%test + + zletest $'one two\ebmt3|`tx``' +0:setting mark and returning to original position +>BUFFER: one wo +>CURSOR: 2 + +%clean + + zmodload -ui zsh/zpty 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=" "fi=" "di=" "ln=" "pi=" "so=" "bd=" "cd=" "ex=" "mi=" "tc=" "sp=" "lc=" "ec=\n" "rc=" @@ -60,18 +62,29 @@ list-choices-with-report () { zle clear-screen zle -R } -finish () { +comp-finish () { print "" zle kill-whole-line zle clear-screen zle -R } +zle-finish () { + print -lr "" "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 "***" || { + print "failed to invoke finish widget." + return 1 + } + print -lr "${(@)${(ps:\r\n:)log##*}[1,-2]}" +} -- cgit 1.4.1