Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
zle test cases (Re: PATCH: save last position in vi-goto-mark)
- X-seq: zsh-workers 31041
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: zle test cases (Re: PATCH: save last position in vi-goto-mark)
- Date: Sun, 10 Feb 2013 23:11:46 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1360534307; bh=b0DWu37qKMhwqOZE/CuVIbMo8peZ+XdgJ2ZSIS+wGDk=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Received:To:From:References:Subject:Date:Message-ID; b=4hFIhsdy3MoEugPTcDo/N92akGfPO8msmLqhHmIUsOAHvJh8ACdsUuI2NNNUd/rJLoZl4YsL8Def1F24hN/Zlua0aXfba47KGXgdtXPLWL4K/8vnMy2v4aII1g+WxQF5pE40WSeDht6nuyq7mUHU2DFK0cS1S8ElFWSz2190OMk=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <22481.1360362438@quattro>
I would have added a test case along with the recent patch but we don't
yet have any tests for zle. I had a look and it seemed that not much
needed changing to comptest to support testing zle widgets. With the
following patch, it will report the buffer contents, cursor position and
mark (if the region is active). Is anything more needed? Any other
thoughts on this?
comptest should perhaps be renamed as completion is sooner a part of zle
than zle a part of completion.
Oliver
Index: Test/X02zlevi.ztst
===================================================================
RCS file: Test/X02zlevi.ztst
diff -N Test/X02zlevi.ztst
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Test/X02zlevi.ztst 10 Feb 2013 21:51:46 -0000
@@ -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
Index: Test/comptest
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/comptest,v
retrieving revision 1.18
diff -u -r1.18 comptest
--- Test/comptest 13 Jan 2009 12:09:26 -0000 1.18
+++ Test/comptest 10 Feb 2013 21:51:46 -0000
@@ -8,10 +8,12 @@
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 @@
"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 @@
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 @@
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]}"
+}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author