summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-05-17 12:31:32 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-05-17 12:31:32 +0000
commit20a527fcaa555387a69fe941298d1ab04eccc88b (patch)
tree8ab03f801c116b7e734089ee70145522e1025811
parent05d3c175a5f9d1eb7bd8ed5f9c36ff5838ee6b8e (diff)
downloadzsh-20a527fcaa555387a69fe941298d1ab04eccc88b.tar.gz
zsh-20a527fcaa555387a69fe941298d1ab04eccc88b.zip
11441: Test/comptest, Test/53completion.ztst,
Test/54compmatch.ztst: use only one zsh process to test for each completion test file.
-rw-r--r--ChangeLog6
-rw-r--r--Test/53completion.ztst74
-rw-r--r--Test/54compmatch.ztst91
-rw-r--r--Test/comptest140
4 files changed, 157 insertions, 154 deletions
diff --git a/ChangeLog b/ChangeLog
index 369177c80..efa6067cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2000-05-17 Tanaka Akira <akr@zsh.org>
+
+ * 11441: Test/comptest, Test/53completion.ztst,
+ Test/54compmatch.ztst: use only one zsh process to test for each
+ completion test file.
+
2000-05-17 Sven Wischnowsky <wischnow@zsh.org>
* Felix: 11397 and my 11439: Doc/Zsh/compwid.yo, Src/Zle/comp.h,
diff --git a/Test/53completion.ztst b/Test/53completion.ztst
index e799052e0..b548a9bf7 100644
--- a/Test/53completion.ztst
+++ b/Test/53completion.ztst
@@ -1,15 +1,13 @@
# Tests for completion system.
%prep
- zmodload -i zsh/zpty
-
- TERM=vt100
- export ZTST_testdir ZTST_srcdir TERM
- comptest () { $ZTST_testdir/../Src/zsh -f $ZTST_srcdir/comptest -z $ZTST_testdir/../Src/zsh -d $ZTST_testdir/compdump.tmp "$@" }
+ . $ZTST_srcdir/comptest
mkdir comp.tmp
cd comp.tmp
+ comptestinit -z $ZTST_testdir/../Src/zsh
+
mkdir dir1
mkdir dir2
touch file1
@@ -32,7 +30,8 @@
>line: {: dir1/}{}
>line: {: dir2/}{}
- comptest -c '_users () { compadd user1 user2 }' $': ~\t\t\t\t\t'
+ comptesteval '_users () { compadd user1 user2 }'
+ comptest $': ~\t\t\t\t\t'
0:tilde
>line: {: ~user}{}
>line: {: ~user}{}
@@ -42,99 +41,108 @@
>line: {: ~user2}{}
>line: {: ~user1}{}
- code='compdef _tst tst; _tst () { _arguments ":desc1:(arg1)" }'
- comptest -c "$code" $'tst \t'
+ comptest $'echo ;:\C-b\C-b\t'
+0:tilde
+>line: {echo }{;:}
+>DESCRIPTION:{file}
+>DI:{dir1}
+>DI:{dir2}
+>FI:{file1}
+>FI:{file2}
+
+ comptesteval 'compdef _tst tst; _tst () { _arguments ":desc1:(arg1)" }'
+ comptest $'tst \t'
0:_arguments
>line: {tst arg1 }{}
- comptest -c "$code" $'tst a\t'
+ comptest $'tst a\t'
0:_arguments
>line: {tst arg1 }{}
- comptest -c "$code" $'tst ar\t'
+ comptest $'tst ar\t'
0:_arguments
>line: {tst arg1 }{}
- comptest -c "$code" $'tst arg\t'
+ comptest $'tst arg\t'
0:_arguments
>line: {tst arg1 }{}
- comptest -c "$code" $'tst arg1\t'
+ comptest $'tst arg1\t'
0:_arguments
>line: {tst arg1 }{}
- comptest -c "$code" $'tst r\t'
+ comptest $'tst r\t'
0:_arguments
>line: {tst r}{}
- comptest -c "$code" $'tst x\t'
+ comptest $'tst x\t'
0:_arguments
>line: {tst x}{}
- comptest -c "$code" $'tst a \t'
+ comptest $'tst a \t'
0:_arguments
>line: {tst a }{}
>MESSAGE:{no more arguments}
- comptest -c "$code" $'tst a b \t'
+ comptest $'tst a b \t'
0:_arguments
>line: {tst a b }{}
>MESSAGE:{no more arguments}
- code='compdef _tst tst; _tst () { _arguments ":desc1:(a b)" }'
- comptest -c "$code" $'tst \t'
+ comptesteval 'compdef _tst tst; _tst () { _arguments ":desc1:(a b)" }'
+ comptest $'tst \t'
0:_arguments
>line: {tst }{}
>DESCRIPTION:{desc1}
>NO:{a}
>NO:{b}
- code='compdef _tst tst; _tst () { _arguments ":desc1:(arg1)" ":desc2:(arg2)" ":desc3:(arg3)" }'
- comptest -c "$code" $'tst \t'
+ comptesteval 'compdef _tst tst; _tst () { _arguments ":desc1:(arg1)" ":desc2:(arg2)" ":desc3:(arg3)" }'
+ comptest $'tst \t'
0:_arguments
>line: {tst arg1 }{}
- comptest -c "$code" $'tst arg1 \t'
+ comptest $'tst arg1 \t'
0:_arguments
>line: {tst arg1 arg2 }{}
- comptest -c "$code" $'tst arg1 arg2 \t'
+ comptest $'tst arg1 arg2 \t'
0:_arguments
>line: {tst arg1 arg2 arg3 }{}
- comptest -c "$code" $'tst \C-D'
+ comptest $'tst \C-D'
0:_arguments
>DESCRIPTION:{desc1}
>NO:{arg1}
- code='compdef _tst tst; _tst () { _arguments "-\+[opt]" }'
- comptest -c "$code" $'tst -\C-D'
+ comptesteval 'compdef _tst tst; _tst () { _arguments "-\+[opt]" }'
+ comptest $'tst -\C-D'
0:_arguments
>DESCRIPTION:{option}
>NO:{-+ -- opt}
- code='compdef _tst tst; _tst () { _arguments "1:desc1:(arg1)" }'
- comptest -c "$code" $'tst \t'
+ comptesteval 'compdef _tst tst; _tst () { _arguments "1:desc1:(arg1)" }'
+ comptest $'tst \t'
0:_arguments
>line: {tst arg1 }{}
- code='compdef _tst tst; _tst () { _arguments "-x" ":arg:" }'
- comptest -c "$code" $'tst -\t'
+ comptesteval 'compdef _tst tst; _tst () { _arguments "-x" ":arg:" }'
+ comptest $'tst -\t'
0:_arguments
>line: {tst -}{}
>MESSAGE:{arg}
- code='compdef _tst tst; _tst () { _arguments "-x:arg:" }'
- comptest -c "$code" $'tst -x\t'
+ comptesteval 'compdef _tst tst; _tst () { _arguments "-x:arg:" }'
+ comptest $'tst -x\t'
0:_arguments
>line: {tst -x }{}
- code='
+ comptesteval '
compdef _tst tst
_tst () { _arguments "-a" "*::rest:_tst2" }
_tst2 () { compadd - -b }
'
- comptest -c "$code" $'tst arg -\t'
+ comptest $'tst arg -\t'
0:_arguments
>line: {tst arg -b }{}
diff --git a/Test/54compmatch.ztst b/Test/54compmatch.ztst
index 7c55134f0..07e988f6b 100644
--- a/Test/54compmatch.ztst
+++ b/Test/54compmatch.ztst
@@ -11,15 +11,12 @@
# contains the compadd output.
%prep
- zmodload -i zsh/zpty
-
- TERM=vt100
- export ZTST_testdir ZTST_srcdir TERM
- comptest () { $ZTST_testdir/../Src/zsh -f $ZTST_srcdir/comptest -z $ZTST_testdir/../Src/zsh -d $ZTST_testdir/compdump.tmp "$@" }
+ . $ZTST_srcdir/comptest
mkdir match.tmp
cd match.tmp
+ comptestinit -z $ZTST_testdir/../Src/zsh
list1=(IndianRed IndianRed2 IndianRed3 IndianRed4)
test_code () {
@@ -28,87 +25,87 @@
code="compdef _tst tst ; _tst () { echo -n '<COMPADD>';compadd -M '"
code="$code$matcher"
code="$code' - ${(P)list} ; echo -n '</COMPADD>'}"
+ comptesteval "$code"
}
%test
-
test_code z: list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
0:Match Error for "z:"
>line: {tst }{}
>COMPADD:{_tst:compadd: unknown match specification character `z'}
test_code m: list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
0:Match Error for "m:"
>line: {tst }{}
>COMPADD:{_tst:compadd: missing patterns}
test_code M: list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
0:Match Error for "M:"
>line: {tst }{}
>COMPADD:{_tst:compadd: missing patterns}
test_code r: list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
0:Match Error "r:"
>line: {tst }{}
>COMPADD:{_tst:compadd: missing patterns}
test_code R: list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
0:Match Error "R:"
>line: {tst }{}
>COMPADD:{_tst:compadd: missing patterns}
test_code l: list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
0:Match Error for "l:"
>line: {tst }{}
>COMPADD:{_tst:compadd: missing patterns}
test_code L: list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
0:Match Error for "L:"
>line: {tst }{}
>COMPADD:{_tst:compadd: missing patterns}
test_code 'm:{0-9' list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
0:Match Error for "m:{0-9"
>line: {tst }{}
>COMPADD:{_tst:compadd: unterminated character class}
test_code 'm:{0-9}' list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
0:Match Error for "m:{0-9}"
>line: {tst }{}
>COMPADD:{_tst:compadd: missing word pattern}
test_code 'm:{0-9}={' list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
0:Match Error for "m:{0-9}={"
>line: {tst }{}
>COMPADD:{_tst:compadd: unterminated character class}
test_code 'm:{0-9}={0-' list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
0:Match Error for "m:{0-9}={0-"
>line: {tst }{}
>COMPADD:{_tst:compadd: unterminated character class}
test_code 'm:{0-9}={-' list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
0:Match Error for "m:{0-9}={-"
>line: {tst }{}
>COMPADD:{_tst:compadd: unterminated character class}
test_code r: list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
0:Match Error "r:"
>line: {tst }{}
>COMPADD:{_tst:compadd: missing patterns}
@@ -123,26 +120,26 @@
)
options_matcher='L:|[nN][oO]= M:_= M:{A-Z}={a-z}'
test_code $options_matcher example1_list
- comptest -c "$code" $'tst nolistbee\t'
+ comptest $'tst nolistbee\t'
0:Documentation example for options, input "nolistbee"
>line: {tst nolistbeep }{}
>COMPADD:{}
test_code $options_matcher example1_list
- comptest -c "$code" $'tst list_bee\t'
+ comptest $'tst list_bee\t'
0:Documentation example for options, input "list_bee"
>line: {tst list_beep }{}
>COMPADD:{}
test_code $options_matcher example1_list
- comptest -c "$code" $'tst ListBee\t'
+ comptest $'tst ListBee\t'
0:Documentation example for options, input "ListBee"
>line: {tst ListBeep }{}
>COMPADD:{}
test_code $options_matcher example1_list
- comptest -c "$code" $'tst NOList\tB\t'
+ comptest $'tst NOList\tB\t'
0:Documentation example for options, input "NOList"
>line: {tst NOList}{}
>COMPADD:{}
@@ -156,7 +153,7 @@
test_code $options_matcher example1_list
- comptest -c "$code" $'tst NO_List\t__\tB\t'
+ comptest $'tst NO_List\t__\tB\t'
0:Documentation example for options, input "NO_List\t__\tB\t"
>line: {tst NO_List}{}
>COMPADD:{}
@@ -176,7 +173,7 @@
>COMPADD:{}
test_code $options_matcher example1_list
- comptest -c "$code" $'tst __\tN\t__o\t___\tlist_\tbeep__\t'
+ comptest $'tst __\tN\t__o\t___\tlist_\tbeep__\t'
0:Documentation example for options, input "__\tN\t__o\t___\tlist_\tbeep__\t"
>line: {tst __}{}
>COMPADD:{}
@@ -204,7 +201,7 @@
>COMPADD:{}
test_code $options_matcher example1_list
- comptest -c "$code" $'tst __\tNo\t___\tlist_\tbeep__\t'
+ comptest $'tst __\tNo\t___\tlist_\tbeep__\t'
0:Documentation example for options, input "__\tNo\t___\tlist_\tbeep__\t"
>line: {tst __}{}
>COMPADD:{}
@@ -231,7 +228,7 @@
test_code $options_matcher example1_list
- comptest -c "$code" $'tst ___\tlist_\tbeep__\t'
+ comptest $'tst ___\tlist_\tbeep__\t'
0:Documentation example for options, input "___\tlist_\tbeep__\t"
>line: {tst ___}{}
>COMPADD:{}
@@ -261,7 +258,7 @@
lower_insensitive_m="m:{a-z}={A-Z}"
example2_list=(ABC Abc abc)
test_code $lower_insensitive_M example2_list
- comptest -c "$code" $'tst ab\tC\t'
+ comptest $'tst ab\tC\t'
0:Documentation example for lowercase insenitive M, input "ab\tC\t"
>line: {tst ab}{}
>COMPADD:{}
@@ -271,7 +268,7 @@
>COMPADD:{}
test_code $lower_insensitive_m example2_list
- comptest -c "$code" $'tst A\t\t'
+ comptest $'tst A\t\t'
0:Documentation example for lowercase insenitive m, input "A\t\t"
>line: {tst A}{}
>COMPADD:{}
@@ -284,7 +281,7 @@
case_insensitive_M="M:{a-zA-Z}={A-Za-z}"
case_insensitive_m="m:{a-zA-Z}={A-Za-z}"
test_code $case_insensitive_M example3_list
- comptest -c "$code" $'tst aB\t\t'
+ comptest $'tst aB\t\t'
0:Documentation example for case insenitive M, input "aB\t\t"
>line: {tst aB}{}
>COMPADD:{}
@@ -295,7 +292,7 @@
test_code $case_insensitive_m example3_list
- comptest -c "$code" $'tst aB\t\t'
+ comptest $'tst aB\t\t'
0:Documentation example for case insenitive m, input "aB\t\t"
>line: {tst a}{BC}
>COMPADD:{}
@@ -317,13 +314,13 @@
comp.graphics.rendering.misc comp.graphics.rendering.raytracing
comp.graphics.rendering.renderman)
test_code $example4_matcher example4_list
- comptest -c "$code" $'tst c.s.u\t'
+ comptest $'tst c.s.u\t'
0:Documentation example using input c.s.u
>line: {tst comp.sources.unix }{}
>COMPADD:{}
test_code $example4_matcher example4_list
- comptest -c "$code" $'tst c.g.\ta\t.\tp\ta\tg\t'
+ comptest $'tst c.g.\ta\t.\tp\ta\tg\t'
0:Documentation example using input c.g.\ta\t.\tp\ta\tg\t
>line: {tst comp.graphics.}{}
>COMPADD:{}
@@ -357,13 +354,13 @@
>COMPADD:{}
test_code $example4_matcher example4_list
- comptest -c "$code" $'tst c...pag\t'
+ comptest $'tst c...pag\t'
0:Documentation example using input c...pag\t
>line: {tst comp.graphics.apps.pagemaker }{}
>COMPADD:{}
test_code $example4_matcher example4_list
- comptest -c "$code" $'tst c...pa\tg\t'
+ comptest $'tst c...pa\tg\t'
0:Documentation example using input c...pa\tg\t
>line: {tst comp.graphics.apps.pa}{}
>COMPADD:{}
@@ -373,7 +370,7 @@
example5_matcher='r:|[.,_-]=* r:|=*'
example5_list=(veryverylongfile.c veryverylongheader.h)
test_code $example5_matcher example5_list
- comptest -c "$code" $'tst v.c\tv.h\t'
+ comptest $'tst v.c\tv.h\t'
0:Documentation example using input v.c\t
>line: {tst veryverylongfile.c }{}
>COMPADD:{}
@@ -383,19 +380,19 @@
example6_list=(LikeTHIS FooHoo 5foo123 5bar234)
test_code 'r:|[A-Z0-9]=* r:|=*' example6_list
- comptest -c "$code" $'tst H\t'
+ comptest $'tst H\t'
0:Documentation example using "r:|[A-Z0-9]=* r:|=*", input H
>line: {tst H}{}
>COMPADD:{}
test_code 'r:|[A-Z0-9]=* r:|=*' example6_list
- comptest -c "$code" $'tst 2\t'
+ comptest $'tst 2\t'
0:Documentation example using "r:|[A-Z0-9]=* r:|=*", input 2
>line: {tst 2}{}
>COMPADD:{}
test_code 'r:|[A-Z0-9]=** r:|=*' example6_list
- comptest -c "$code" $'tst H\t'
+ comptest $'tst H\t'
0:Documentation example using "r:|[A-Z0-9]=* r:|=*", input 2
>line: {tst H}{}
>COMPADD:{}
@@ -403,7 +400,7 @@
>NO:{LikeTHIS}
test_code 'r:|[A-Z0-9]=** r:|=*' example6_list
- comptest -c "$code" $'tst 2\t\t'
+ comptest $'tst 2\t\t'
0:Documentation example using "r:|[A-Z0-9]=* r:|=*", input 2
>line: {tst 523}{}
>COMPADD:{}
@@ -415,7 +412,7 @@
example7_matcher="r:[^A-Z0-9]||[A-Z0-9]=** r:|=*"
example7_list=($example6_list)
test_code $example7_matcher example7_list
- comptest -c "$code" $'tst H\t2\t'
+ comptest $'tst H\t2\t'
0:Documentation example using "r:[^A-Z0-9]||[A-Z0-9]=** r:|=*"
>line: {tst FooHoo }{}
>COMPADD:{}
@@ -426,13 +423,13 @@
workers_7311_matcher="m:{a-z}={A-Z} r:|[.,_-]=* r:|=*"
workers_7311_list=(Abc-Def-Ghij.txt Abc-def.ghi.jkl_mno.pqr.txt Abc_def_ghi_jkl_mno_pqr.txt)
test_code $workers_7311_matcher workers_7311_list
- comptest -c "$code" $'tst a-a\t'
+ comptest $'tst a-a\t'
0:Bug from workers 7311
>line: {tst a-a}{}
>COMPADD:{}
test_code $workers_7311_matcher workers_7311_list
- comptest -c "$code" $'tst a\t\t-d.\t'
+ comptest $'tst a\t\t-d.\t'
0:Bug from workers_7311
>line: {tst Abc}{}
>COMPADD:{}
@@ -447,7 +444,7 @@
workers_10886_matcher="r:|[A-Z0-9]=* r:|=*"
workers_10886_list=(BW UWB W)
test_code $workers_10886_matcher workers_10886_list
- comptest -c "$code" $'tst W\t'
+ comptest $'tst W\t'
0:Bug from workers 10886
>line: {tst W }{}
>COMPADD:{}
@@ -455,7 +452,7 @@
workers_11081_matcher='m:{a-zA-Z}={A-Za-z} r:|[.,_-]=* r:[^A-Z0-9]||[A-Z0-9]=* r:[A-Z0-9]||[^A-Z0-9]=* r:[^0-9]||[0-9]=* r:|=*'
workers_11081_list=(build.out build.out1 build.out2)
test_code $workers_11081_matcher workers_11081_list
- comptest -c "$code" $'tst bui\t\t\t'
+ comptest $'tst bui\t\t\t'
0:Bug from workers 11081
>line: {tst build.out}{}
>COMPADD:{}
@@ -471,7 +468,7 @@
workers_11388_matcher='r:|[:.]=* r:|=*'
workers_11388_list=(a.b:0 c.d:1)
test_code $workers_11388_matcher workers_11388_list
- comptest -c "$code" $'tst :\t'
+ comptest $'tst :\t'
0:Non-bug from workers 11388
>line: {tst :}{}
>COMPADD:{}
@@ -479,7 +476,7 @@
workers_11388_matcher='r:|[:.]=** r:|=*'
workers_11388_list=(a.b:0 c.d:1)
test_code $workers_11388_matcher workers_11388_list
- comptest -c "$code" $'tst :\t'
+ comptest $'tst :\t'
0:Non-bug from workers 11388
>line: {tst }{.:}
>COMPADD:{}
diff --git a/Test/comptest b/Test/comptest
index 6a37bb15e..0b6962d6e 100644
--- a/Test/comptest
+++ b/Test/comptest
@@ -1,39 +1,34 @@
-#!/usr/local/bin/zsh -f
+comptestinit () {
+ setopt extendedglob
+ [[ -d $ZTST_testdir/Modules/zsh ]] && module_path=( $ZTST_testdir/Modules )
+ fpath=( $ZTST_srcdir/../(Completion|Functions)/*~*/CVS(/) )
-[[ -d $ZTST_testdir/Modules/zsh ]] && module_path=( $ZTST_testdir/Modules )
+ zmodload -i zsh/zpty
-zmodload -i zsh/zpty
-setopt extendedglob
+ comptest_zsh=${ZSH:-zsh}
+ termcap_ce="$(echotc ce)"
-fpath=( $ZTST_srcdir/../(Completion|Functions)/*~*/CVS(/) )
-
-debug=
-dump=(-D)
-code=
-zsh=${ZSH:-zsh}
-termcap_ce="$(echotc ce)"
-
-debug=yes
-while getopts Dd:c:z: opt; do
- case $opt in
- D) debug=yes;;
- d) dump=(-d "$OPTARG");;
- c) code="$OPTARG";;
- z) zsh="$OPTARG";;
- esac
-done
-(( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
+ while getopts z: opt; do
+ case $opt in
+ z) comptest_zsh="$OPTARG";;
+ esac
+ done
+ (( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
-input="$*"
+ export PS1="<PROMPT>"
+ zpty zsh "$comptest_zsh" -f
-tmp=/tmp/comptest.$$
+ zpty -r zsh log1 "*<PROMPT>*" || {
+ print "first prompt doesn't appered."
+ return 1
+ }
-cat <<End >$tmp
-module_path=( $module_path )
-fpath=( $fpath )
+ comptesteval \
+"module_path=( $module_path )" \
+"fpath=( $fpath )" \
+"ZLS_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>'" \
+'LISTMAX=10000000
stty columns 80 rows 24
-LISTMAX=10000000
-ZLS_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>'
bindkey -e
autoload -U compinit
compinit $dump
@@ -49,7 +44,7 @@ zmodload zsh/complist
expand-or-complete-with-report () {
print -lr "<WIDGET><expand-or-complete>"
zle expand-or-complete
- print -lr - "<LBUFFER>\$LBUFFER</LBUFFER>" "<RBUFFER>\$RBUFFER</RBUFFER>"
+ print -lr - "<LBUFFER>$LBUFFER</LBUFFER>" "<RBUFFER>$RBUFFER</RBUFFER>"
zle clear-screen
zle -R
}
@@ -61,8 +56,9 @@ list-choices-with-report () {
}
finish () {
print "<WIDGET><finish>"
- sleep 1
- exit 0
+ zle kill-whole-line
+ zle clear-screen
+ zle -R
}
zle -N expand-or-complete-with-report
zle -N list-choices-with-report
@@ -70,54 +66,50 @@ zle -N finish
bindkey "^I" expand-or-complete-with-report
bindkey "^D" list-choices-with-report
bindkey "^Z" finish
-$code
-End
-
-export PS1="<PROMPT>"
-zpty zsh "$zsh" -f
-
-zpty -r zsh log1 "*<PROMPT>*" || {
- print first prompt doesn\'t appered.
- exit 1
+'
}
-zpty -w zsh ". $tmp"
-zpty -r zsh log2 "*<PROMPT>*" || {
- print second prompt doesn\'t appered.
- exit 1
-}
-rm $tmp
+comptesteval () {
+ local tmp=/tmp/comptest.$$
-zpty -n -w zsh "$input"$'\C-Z'
-zpty -r zsh log "*<WIDGET><finish>*" || {
- print finish widget doesn\'t invoked.
- exit 1
+ print -lr - "$@" > $tmp
+ zpty -w zsh ". $tmp"
+ zpty -r zsh log_eval "*<PROMPT>*" || {
+ print "prompt doesn't appered."
+ return 1
+ }
+ rm $tmp
}
-if [[ -n "$debug" ]]; then
- print -lr - "$log" > /tmp/comptest.debug
-fi
+comptest () {
+ input="$*"
+ zpty -n -w zsh "$input"$'\C-Z'
+ zpty -r zsh log "*<WIDGET><finish>*<PROMPT>*" || {
+ print "finish widget doesn't invoked."
+ return 1
+ }
-logs=(${(s:<WIDGET>:)log})
-shift logs
+ logs=(${(s:<WIDGET>:)log})
+ shift logs
-for log in "$logs[@]"; do
- if [[ "$log" = (#b)*$'<LBUFFER>'(*)$'</LBUFFER>\r\n<RBUFFER>'(*)$'</RBUFFER>'* ]]; then
- print -lr "line: {$match[1]}{$match[2]}"
- fi
- while (( ${(N)log#*(#b)(<LC><(??)><RC>(*)<EC>|<DESCRIPTION>(*)</DESCRIPTION>|<MESSAGE>(*)</MESSAGE>|<COMPADD>(*)</COMPADD>)} )); do
- log="${log[$mend[1]+1,-1]}"
- if (( 0 <= $mbegin[2] )); then
- if [[ $match[2] != TC && $match[3] != \ # ]]; then
- print -lr "$match[2]:{${match[3]%$termcap_ce}}"
- fi
- elif (( 0 <= $mbegin[4] )); then
- print -lr "DESCRIPTION:{$match[4]}"
- elif (( 0 <= $mbegin[5] )); then
- print -lr "MESSAGE:{$match[5]}"
- elif (( 0 <= $mbegin[6] )); then
- result=`echo $match[6] | tr -d '\012\015'`
- print -lr "COMPADD:{$result}"
+ for log in "$logs[@]"; do
+ if [[ "$log" = (#b)*$'<LBUFFER>'(*)$'</LBUFFER>\r\n<RBUFFER>'(*)$'</RBUFFER>'* ]]; then
+ print -lr "line: {$match[1]}{$match[2]}"
fi
+ while (( ${(N)log#*(#b)(<LC><(??)><RC>(*)<EC>|<DESCRIPTION>(*)</DESCRIPTION>|<MESSAGE>(*)</MESSAGE>|<COMPADD>(*)</COMPADD>)} )); do
+ log="${log[$mend[1]+1,-1]}"
+ if (( 0 <= $mbegin[2] )); then
+ if [[ $match[2] != TC && $match[3] != \ # ]]; then
+ print -lr "$match[2]:{${match[3]%$termcap_ce}}"
+ fi
+ elif (( 0 <= $mbegin[4] )); then
+ print -lr "DESCRIPTION:{$match[4]}"
+ elif (( 0 <= $mbegin[5] )); then
+ print -lr "MESSAGE:{$match[5]}"
+ elif (( 0 <= $mbegin[6] )); then
+ result=`echo $match[6] | tr -d '\012\015'`
+ print -lr "COMPADD:{$result}"
+ fi
+ done
done
-done
+}