zsh-workers
 help / color / mirror / code / Atom feed
From: dana <dana@dana.is>
To: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [PATCH] Tests/X04: use temporary pattern matching for OpenBSD missing leading 0m
Date: Tue, 22 Jan 2019 22:27:59 -0600	[thread overview]
Message-ID: <E4311697-FB4E-4F5C-A2B6-A17A07EFAD0D@dana.is> (raw)
In-Reply-To: <CAKc7PVAcNJxUgDOshnJ0d8e5FNqF5c-scCST_ba0Fmr2uuv4_w@mail.gmail.com>

On 22 Jan 2019, at 09:27, Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
>phy1729 reports that OpenBSD doesn't include a leading 0m in its
>control codes output. Thus, X04 tests fail on that OS.

The failure is due to $termcap[me] on OpenBSD using \e(B\e[m where the test
expects \e[0m. After normalising to the latter and stripping \e(B from the
output, it passes. Fiddling about with hard-coded escape sequences feels
pretty brittle to me, but i guess that's what we're already doing, so...
hopefully it's at least better than just dropping the sequence entirely.

(I also fixed some white space; included as a separate diff below.)

Tested on macOS and OpenBSD. It passed for Matthew as well.

dana


diff --git a/Test/X04zlehighlight.ztst b/Test/X04zlehighlight.ztst
index e14517490..9e3b2681b 100644
--- a/Test/X04zlehighlight.ztst
+++ b/Test/X04zlehighlight.ztst
@@ -29,6 +29,8 @@
       integer i
       for (( i = 0; i < ${1:-1}; ++i )); do
         zpty -r zsh REPLY
+        # Normalise me/sgr0 to \e[0m. We also need to strip \e(B in zpty_stop()
+        REPLY=${REPLY//${termcap[me]}/$'\x1b[0m'}
         # P is for "preserve", and induces keeping some
         # expected color codes to test region_highlight,
         # etc. - the color codes are made a regular text.
@@ -54,7 +56,7 @@
       # zpty gives no output when piped without these braces (?)
       # The while loop with // substitution is to convert `e^Mexit'
       # into `exit' (see zpty_line). The sed commands remove escapes
-      { zpty -r zsh } | sed -e $'/[^\t\r ]/!d' -e $'s/\r$//' -e $'s/\x1b\\[[0-9;]*m//g' | while read REPLY; do REPLY=${REPLY//(#b)((?(#c0,1))$cm(?(#c0,1)))/${${${(M)match[2]:#${match[3]}}:+${match[2]}}:-${${match[1]##[[:space:]]##}%%[[:space:]]##}}}; print -rn -- "$REPLY"; done
+      { zpty -r zsh } | sed -e $'/[^\t\r ]/!d' -e $'s/\r$//' -e $'s/\x1b\\[[0-9;]*m//g' -e $'s/\x1b([A-Z]//g' | while read REPLY; do REPLY=${REPLY//(#b)((?(#c0,1))$cm(?(#c0,1)))/${${${(M)match[2]:#${match[3]}}:+${match[2]}}:-${${match[1]##[[:space:]]##}%%[[:space:]]##}}}; print -rn -- "$REPLY"; done
       zpty -d
       :
     }

diff --git a/Test/X04zlehighlight.ztst b/Test/X04zlehighlight.ztst
index 9e3b2681b..b6a8c35fd 100644
--- a/Test/X04zlehighlight.ztst
+++ b/Test/X04zlehighlight.ztst
@@ -56,7 +56,12 @@
       # zpty gives no output when piped without these braces (?)
       # The while loop with // substitution is to convert `e^Mexit'
       # into `exit' (see zpty_line). The sed commands remove escapes
-      { zpty -r zsh } | sed -e $'/[^\t\r ]/!d' -e $'s/\r$//' -e $'s/\x1b\\[[0-9;]*m//g' -e $'s/\x1b([A-Z]//g' | while read REPLY; do REPLY=${REPLY//(#b)((?(#c0,1))$cm(?(#c0,1)))/${${${(M)match[2]:#${match[3]}}:+${match[2]}}:-${${match[1]##[[:space:]]##}%%[[:space:]]##}}}; print -rn -- "$REPLY"; done
+      { zpty -r zsh } |
+      sed -e $'/[^\t\r ]/!d' -e $'s/\r$//' -e $'s/\x1b\\[[0-9;]*m//g' -e $'s/\x1b([A-Z]//g' |
+      while read REPLY; do
+        REPLY=${REPLY//(#b)((?(#c0,1))$cm(?(#c0,1)))/${${${(M)match[2]:#${match[3]}}:+${match[2]}}:-${${match[1]##[[:space:]]##}%%[[:space:]]##}}}
+        print -rn -- "$REPLY"
+      done
       zpty -d
       :
     }


      reply	other threads:[~2019-01-23  4:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-22 15:27 Sebastian Gniazdowski
2019-01-23  4:27 ` dana [this message]

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=E4311697-FB4E-4F5C-A2B6-A17A07EFAD0D@dana.is \
    --to=dana@dana.is \
    --cc=sgniazdowski@gmail.com \
    --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).