zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh-workers@zsh.org
Subject: Re: Commit 137b15a fails X02zlevi test
Date: Sun, 09 Feb 2014 23:30:11 +0100	[thread overview]
Message-ID: <17919.1391985011@quattro> (raw)
In-Reply-To: <140209105343.ZM24252@torch.brasslantern.com>

Bart wrote:
> I've been repeatedly running
> 
>     make check TESTNUM=X02
> 
> and have decided that it fails nondeterministically.  Sometimes the

On my desktop it never seems to fail. I just tried on my NAS box and
it appears to reliably fail there. I don't think the send-break is an
issue because the combination of kill-buffer and accept-line also
exhibit the problem. For the test to be relevant, it needed a new line.

The problem seems somewhat similar to the problems I have with Felix's
incremental search tests except that is failing more consistently for
me. I've attached my modified patch for them in case it provides you
with any clues. They seem to always fail on tests that would produce a
"failing bck-i-search". I'm fairly stuck on trying to understand that
too. Probably need to try to trace the zsh instance that's running under
zpty.

Oliver

diff --git a/Test/X01isearch.ztst b/Test/X01isearch.ztst
new file mode 100644
index 0000000..d683242
--- /dev/null
+++ b/Test/X01isearch.ztst
@@ -0,0 +1,167 @@
+%prep
+  if ( zmodload -i zsh/zpty ) >/dev/null 2>&1; then
+    . $ZTST_srcdir/comptest
+    mkdir zle.tmp
+    cd zle.tmp
+    print -lr date 'echo xyz three' 'echo xyz two' 'echo 123 abc' \
+	'echo abc abcdef' 'echo abc' 'echo xyz' 'echo date' "echo '*OH NO*'" \
+	"echo '\n'" 'echo "*WHAT?*"' > historyX01
+    comptestinit -z $ZTST_testdir/../Src/zsh
+  else
+    ZTST_unimplemented="the zsh/zpty module is not available"
+  fi
+
+%test
+# Tests to add:
+#  case-insesitivity
+#  ignoring duplicate lines
+#  special keys
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-Rabc'
+0q:Verify incremental search first match
+>echo <FG 2><BG 1>abc<FG 9><BG 9>
+>bck-i-search: abc_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-Rabcd\C-H'
+0q:Verify incremental search first match via backspace
+>echo <FG 2><BG 1>abc<FG 9><BG 9>
+>bck-i-search: abc_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\n\C-Rabc\C-R'
+0q:Verify incremental search second match
+>echo abc <FG 2><BG 1>abc<FG 9><BG 9>def
+>bck-i-search: abc_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-Rabc\C-R\C-R'
+0q:Verify incremental search third match
+>echo <FG 2><BG 1>abc<FG 9><BG 9> abcdef
+>bck-i-search: abc_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-Rabc\C-R\C-R\C-R'
+0q:Verify incremental search fourth match
+>echo 123 <FG 2><BG 1>abc<FG 9><BG 9>
+>bck-i-search: abc_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-Rabc\C-R\C-R\C-R\C-R'
+0q:Verify incremental search failed fifth match
+>echo 123 abc
+>failing bck-i-search: abc_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-Rabc\C-R\C-R\C-Rd'
+0q:Verify incremental search pass something
+>echo 123 abc
+>failing bck-i-search: abcd_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-Rabc\C-R\C-R\C-Rd\C-H\C-H\C-Hd'
+0q:Verify incremental search pass, backup, and find again.
+>echo abc <FG 2><BG 1>abcd<FG 9><BG 9>ef
+>bck-i-search: abcd_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-Rabcd\C-T'
+0q:Verify incremental search pass, then use search forward to find.
+>echo abc <FG 2><BG 1>abcd<FG 9><BG 9>ef
+>fwd-i-search: abcd_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-R^date'
+0q:Verify incremental search bol pattern
+><FG 2><BG 1>date<FG 9><BG 9>
+>bck-i-search: ^date_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-R\\'
+0q:Verify incremental search backslash
+>echo '<FG 2><BG 1>\<FG 9><BG 9>n'
+>bck-i-search: \_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-XR\\*'
+0q:Verify incremental search backslash star
+>echo "*WHAT?<FG 2><BG 1>*<FG 9><BG 9>"
+>bck-i-search: \*_
+
+############# incremental pattern search
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-XRabc'
+0q:Verify incremental pattern search first match
+>echo <FG 2><BG 1>abc<FG 9><BG 9>
+>bck-i-search: abc_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-XRabcd\C-H'
+0q:Verify incremental pattern search first match via backspace
+>echo <FG 2><BG 1>abc<FG 9><BG 9>
+>bck-i-search: abc_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\n\C-XRabc\C-XR'
+0q:Verify incremental pattern search second match
+>echo abc <FG 2><BG 1>abc<FG 9><BG 9>def
+>bck-i-search: abc_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-XRabc\C-XR\C-XR'
+0q:Verify incremental pattern search third match
+>echo <FG 2><BG 1>abc<FG 9><BG 9> abcdef
+>bck-i-search: abc_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-XRabc\C-XR\C-XR\C-XR'
+0q:Verify incremental pattern search fourth match
+>echo 123 <FG 2><BG 1>abc<FG 9><BG 9>
+>bck-i-search: abc_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-XRabc\C-XR\C-XR\C-XR\C-XR'
+0q:Verify incremental pattern search failed fifth match
+>echo 123 abc
+>failing bck-i-search: abc_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-XRabc\C-XR\C-XR\C-XRd'
+0q:Verify incremental pattern search pass something
+>echo 123 abc
+>failing bck-i-search: abcd_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-XRabc\C-XR\C-XR\C-XRd\C-H\C-H\C-Hd'
+0q:Verify incremental pattern search pass, backup, and find again.
+>echo abc <FG 2><BG 1>abcd<FG 9><BG 9>ef
+>bck-i-search: abcd_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-XRabcd\C-XT'
+0q:Verify incremental pattern search pass, then use search forward to find.
+>echo abc <FG 2><BG 1>abcd<FG 9><BG 9>ef
+>fwd-i-search: abcd_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-XR^date'
+0q:Verify incremental pattern search bol pattern
+><FG 2><BG 1>date<FG 9><BG 9>
+>bck-i-search: ^date_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-XR\\'
+0q:Verify incremental pattern search backslash
+>echo '<FG 2><BG 1>\<FG 9><BG 9>n'
+>bck-i-search: \_
+
+ comptesteval 'fc -R historyX01'
+ termtest $'\C-XR\\*'
+0q:Verify incremental pattern search backslash star
+>echo "*WHAT?<FG 2><BG 1>*<FG 9><BG 9>"
+>bck-i-search: \*_
+
+%clean
+  zmodload -ui zsh/zpty
diff --git a/Test/comptest b/Test/comptest
index f1c5af0..8a11ca9 100644
--- a/Test/comptest
+++ b/Test/comptest
@@ -18,10 +18,10 @@ comptestinit () {
   done
   (( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
 
-  export PS1="<PROMPT>"
+  export PS1="<PROMPT>" PS2="" RPS1="" RPS2=""
   zpty zsh "$comptest_zsh -f +Z"
 
-  zpty -r zsh log1 "*<PROMPT>*" || { 
+  zpty -r zsh log1 "*<PROMPT>*" || {
     print "first prompt hasn't appeared."
     return 1
   }
@@ -32,6 +32,7 @@ comptestinit () {
 "export ZDOTDIR=$ZTST_testdir" \
 "module_path=( $module_path )" \
 "fpath=( $fpath )" \
+"zle_highlight=(bg_start_code:'\<BG ' bg_end_code:'\>' fg_start_code:'\<FG ' fg_end_code:'\>' isearch:bg=1,fg=2)" \
 "bindkey -$comptest_keymap" \
 'LISTMAX=10000000
 stty 38400 columns 80 rows 24
@@ -62,6 +63,14 @@ list-choices-with-report () {
   zle clear-screen
   zle -R
 }
+tcfunc() {
+  if [[ -n $2 ]]; then
+    REPLY="<tc=$1,arg=$2>"
+  else
+    REPLY="<tc=$1>"
+  fi
+}
+zle -T tc tcfunc
 comp-finish () {
   print "<WIDGET><finish>"
   zle kill-whole-line
@@ -73,18 +82,30 @@ zle-finish () {
   (( region_active )) && print -lr "MARK: $MARK"
   zle -K main
   zle clear-screen
+  zle -R
   zle send-break
+}
+term-finish () {
+  zle kill-buffer
+  zle clear-screen
+  print "<finish>"
   zle -R
 }
 zle -N expand-or-complete-with-report
 zle -N list-choices-with-report
 zle -N comp-finish
+zle -N term-finish
 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 "^T" history-incremental-search-forward
+bindkey "^XR" history-incremental-pattern-search-backward
+bindkey "^XT" history-incremental-pattern-search-forward
+bindkey -r "^M"
+bindkey "^Mc" comp-finish
+bindkey "^Mt" term-finish
+bindkey "^Mz" zle-finish
+bindkey -a "^Mz" zle-finish
 '
 }
 
@@ -102,7 +123,7 @@ comptesteval () {
 
 comptest () {
   input="$*"
-  zpty -n -w zsh "$input"$'\C-Z'
+  zpty -n -w zsh "$input"$'\C-Mc'
   zpty -r -m zsh log "*<WIDGET><finish>*<PROMPT>*" || {
     print "failed to invoke finish widget."
     return 1
@@ -136,10 +157,26 @@ comptest () {
 
 zletest () {
   input="$*"
-  zpty -n -w zsh "$input"$'\C-M'
+  zpty -n -w zsh "$input"$'\C-Mz'
   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]}"
 }
+
+termtest () {
+  input="$*"
+  zpty -n -w zsh "$input"
+  # clear screen, to clear out control sequences
+  zpty -n -w zsh $'\C-L'
+  # send trailing output to scrape off.
+  zpty -n -w zsh $'\C-Mt\C-U'
+  zpty -r -m zsh log "*<finish>*<PROMPT>" || {
+    print "failed to invoke finish widget."
+    return 1
+  }
+  # there might be multiple <PROMPT>'s in log, grab the last one
+  # generated after the clear screen.
+  print -lr -- ${${(f)${log%%<finish>*}##*<PROMPT>}%%<tc=c?>*}
+}


  parent reply	other threads:[~2014-02-09 22:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-08 20:13 Bart Schaefer
2014-02-08 22:45 ` Bart Schaefer
2014-02-09 18:53   ` Bart Schaefer
2014-02-09 21:00     ` Peter Stephenson
2014-02-09 22:30     ` Oliver Kiddle [this message]
2014-02-11  7:37       ` Bart Schaefer
2014-02-13  5:49         ` Bart Schaefer
2014-02-13  9:32           ` Peter Stephenson
2014-02-13 16:17           ` Jun T.
2014-02-13 17:39             ` Bart Schaefer
2014-02-14 15:59               ` Jun T.
2014-02-15  1:42                 ` Bart Schaefer
2014-02-15 17:07                   ` Jun T.
2014-02-15 21:35                     ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17919.1391985011@quattro \
    --to=okiddle@yahoo.co.uk \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).