zsh-workers
 help / Atom feed
* [PATCH] Tests/X04: use temporary pattern matching for OpenBSD missing leading 0m
@ 2019-01-22 15:27 Sebastian Gniazdowski
  2019-01-23  4:27 ` dana
  0 siblings, 1 reply; 2+ messages in thread
From: Sebastian Gniazdowski @ 2019-01-22 15:27 UTC (permalink / raw)
  To: Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 584 bytes --]

phy1729 reports that OpenBSD doesn't include a leading 0m in its
control codes output. Thus, X04 tests fail on that OS. The temporary
solution is: use pattern matching with leading (0m|), e.g.:

->0m27m24mtr7mu27me word2 word3
+*>(0m|)27m24mtr7mu27me word2 word3

Attached patch does this. In longer term one will have to debug zsh on OpenBSD.

The phy1729's message:
https://gist.github.com/phy1729/6206469618627afd031c167c26a3bf3c
-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

[-- Attachment #2: X04zlehighlight_OpenBSD_fauils.patch.txt --]
[-- Type: text/plain, Size: 2951 bytes --]

From 349fe27b670bc2168e9829f33d61162f32318585 Mon Sep 17 00:00:00 2001
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Date: Tue, 22 Jan 2019 16:18:08 +0100
Subject: [PATCH] Tests/X04: use temporary pattern matching for OpenBSD missing
 leading 0m

---
 Test/X04zlehighlight.ztst | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/Test/X04zlehighlight.ztst b/Test/X04zlehighlight.ztst
index e14517490..110de1251 100644
--- a/Test/X04zlehighlight.ztst
+++ b/Test/X04zlehighlight.ztst
@@ -74,7 +74,7 @@
   zpty_line 1 p       # the line of interest, preserving escapes ("p")
   zpty_stop
 0:region highlight - standout overlapping on other region_highlight entry
->0m27m24mtr7mu27me word2 word3
+*>(0m|)27m24mtr7mu27me word2 word3
 
   zpty_start
   zpty_input 'rh_widget() { BUFFER="true"; region_highlight+=( "0 4 fg=green" ); }'
@@ -85,7 +85,7 @@
   zpty_line 1 p       # the line of interest, preserving escapes ("p")
   zpty_stop
 0:basic region_highlight with 8 colors
->0m27m24mCDE|32|trueCDE|39|
+*>(0m|)27m24mCDE\|32\|trueCDE\|39\|
 
   zpty_start
   zpty_input 'rh_widget() { BUFFER="true"; region_highlight+=( "0 4 fg=#040810" ); }'
@@ -96,7 +96,7 @@
   zpty_line 1 p       # the line of interest, preserving escapes ("p")
   zpty_stop
 0:basic region_highlight with true-color (hex-triplets)
->0m27m24mCDE|38;2;4;8;16|trueCDE|39|
+*>(0m|)27m24mCDE\|38;2;4;8;16\|trueCDE\|39\|
 
   zpty_start
   zpty_input 'zmodload zsh/nearcolor'
@@ -108,7 +108,7 @@
   zpty_line 1 p       # the line of interest, preserving escapes ("p")
   zpty_stop
 0:basic region_highlight with near-color (hex-triplets at input)
->0m27m24mCDE|38;5;232|trueCDE|39|
+*>(0m|)27m24mCDE\|38;5;232\|trueCDE\|39\|
 
   zpty_start
   zpty_input 'rh_widget() { BUFFER="true"; region_highlight+=( "0 4 fg=green" ); rh2; }'
@@ -120,7 +120,7 @@
   zpty_line 1 p       # the line of interest, preserving escapes ("p")
   zpty_stop
 0:overlapping region_highlight with 8 colors
->0m27m24mCDE|32|tCDE|31|rCDE|39|CDE|32|ueCDE|39|
+*>(0m|)27m24mCDE\|32\|tCDE\|31\|rCDE\|39\|CDE\|32\|ueCDE\|39\|
 
   zpty_start
   zpty_input 'rh_widget() { BUFFER="true"; region_highlight+=( "0 4 fg=#00cc00" ); rh2; }'
@@ -132,7 +132,7 @@
   zpty_line 1 p       # the line of interest, preserving escapes ("p")
   zpty_stop
 0:overlapping region_highlight with true-color
->0m27m24mCDE|38;2;0;204;0|tCDE|38;2;204;0;0|rCDE|39|CDE|38;2;0;204;0|ueCDE|39|
+*>(0m|)27m24mCDE\|38;2;0;204;0\|tCDE\|38;2;204;0;0\|rCDE\|39\|CDE\|38;2;0;204;0\|ueCDE\|39\|
 
   zpty_start
   zpty_input 'zmodload zsh/nearcolor'
@@ -145,7 +145,7 @@
   zpty_line 1 p       # the line of interest, preserving escapes ("p")
   zpty_stop
 0:overlapping region_highlight with near-color (hex-triplets at input)
->0m27m24mCDE|38;5;40|tCDE|38;5;160|rCDE|39|CDE|38;5;40|ueCDE|39|
+*>(0m|)27m24mCDE\|38;5;40\|tCDE\|38;5;160\|rCDE\|39\|CDE\|38;5;40\|ueCDE\|39\|
 
 %clean
 
-- 
2.15.1 (Apple Git-101)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Tests/X04: use temporary pattern matching for OpenBSD missing leading 0m
  2019-01-22 15:27 [PATCH] Tests/X04: use temporary pattern matching for OpenBSD missing leading 0m Sebastian Gniazdowski
@ 2019-01-23  4:27 ` dana
  0 siblings, 0 replies; 2+ messages in thread
From: dana @ 2019-01-23  4:27 UTC (permalink / raw)
  To: Sebastian Gniazdowski; +Cc: Zsh hackers list

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
       :
     }


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-22 15:27 [PATCH] Tests/X04: use temporary pattern matching for OpenBSD missing leading 0m Sebastian Gniazdowski
2019-01-23  4:27 ` dana

zsh-workers

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-workers

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


AGPL code for this site: git clone https://public-inbox.org/ public-inbox