Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] V15nearcolor.ztst: use rxvt-unicode as another 88-color terminal



Ubuntu {22,24,26}.04 LTS does not have xterm-88color
(in default installation), and all of the tests in
V15nearcolor are skipped.

The patch below checks for rxvt-unicode (exists in Ubuntu) as
another possibility of 88-color terminal.

If one of 88 or 256 color terminals is not found, only part of
the tests for that number of colors is skipped.

# Are there any 256-color terminals that should be checked for if
# xterm-256color is not available?



diff --git a/Test/V15nearcolor.ztst b/Test/V15nearcolor.ztst
index aa09cb87c..9f9a80835 100644
--- a/Test/V15nearcolor.ztst
+++ b/Test/V15nearcolor.ztst
@@ -6,32 +6,45 @@
     ZTST_unimplemented='the zsh/nearcolor module is not available'
   elif ! zmodload -s zsh/terminfo; then
     ZTST_unimplemented='the zsh/terminfo module is not available'
-  elif ! ( TERM=xterm-88color; [[ $terminfo[colors] == 88 ]] ) 2> /dev/null; then
-    ZTST_unimplemented='the xterm-88color terminal definition is not available'
-  elif ! ( TERM=xterm-256color; [[ $terminfo[colors] == 256 ]] ) 2> /dev/null; then
-    ZTST_unimplemented='the xterm-256color terminal definition is not available'
   fi
-  typeset -a .term.extensions=( )
+
+  term88= term256=
+  local t
+  for t in xterm-88color rxvt-unicode; do
+    if ( TERM=$t; [[ $terminfo[colors] == 88 ]] ) 2> /dev/null; then
+      term88=$t
+      break
+    fi
+  done
+  # XXX any other 256-color terminals?
+  for t in xterm-256color; do
+    if ( TERM=$t; [[ $terminfo[colors] == 256 ]] ) 2> /dev/null; then
+      term256=$t
+      break
+    fi
+  done
+  if [[ -z $term88 && -z $term256 ]]; then
+    ZTST_unimplemented='no 88- and 256-color terminals'
+  else
+    print -u $ZTST_fd "88-color terminal:  ${term88:-not found}"
+    print -u $ZTST_fd "256-color terminal: ${term256:-not found}"
+  fi
 
 %test
 
-  for 1 in xterm-{88,256}color; do
+  for 1 in $term88 $term256; do
     for 2 in '' -truecolor; do (
       TERM=$1
       typeset -a .term.extensions=( $2 )
       zmodload -iu zsh/nearcolor
       zmodload | grep -q zsh/nearcolor && echo unexpectedly loaded
       : ${(%):-'%F{#123456}'}
-      zmodload | grep zsh/nearcolor
+      zmodload | grep -q zsh/nearcolor || echo not autoloaded
     ); done
   done
 0:automatically loaded without truecolor extension
->zsh/nearcolor
->zsh/nearcolor
->zsh/nearcolor
->zsh/nearcolor
 
-  for 1 in xterm-{88,256}color; do (
+  for 1 in $term88 $term256; do (
     TERM=$1
     typeset -a .term.extensions=( truecolor )
     zmodload -iu zsh/nearcolor
@@ -42,12 +55,16 @@
 1:not automatically loaded with truecolor extension
 
 # see https://github.com/exg/rxvt-unicode/blob/5865a435983be27c/src/init.C#L213
+  if [[ -z $term88 ]]; then
+    ZTST_skip='88-color conversion (no 88-color terminal)'
+  else
   (
-    TERM=xterm-88color
+    TERM=$term88
     for 1 in 123456 654321 8a6cb4 8bffcd a5e02d cccccc d0d0d0 f00 0f0 00f; do
       print -r - $1 ${(V)${(%):-"%F{#$1}"}}
     done
   )
+  fi
 0:88-colour conversion
 >123456 ^[[38;5;80m
 >654321 ^[[38;5;81m
@@ -61,12 +78,16 @@
 >00f ^[[38;5;19m
 
 # see https://github.com/exg/rxvt-unicode/blob/5865a435983be27c/src/init.C#L293
+  if [[ -z $term256 ]]; then
+    ZTST_skip='256-color conversion (no 256-color terminal)'
+  else
   (
-    TERM=xterm-256color
+    TERM=$term256
     for 1 in 123456 654321 87af5f 8a6cb4 a5e02d cccccc d0d0d0 f00 0f0 00f; do
       print -r - $1 ${(V)${(%):-"%F{#$1}"}}
     done
   )
+  fi
 0:256-colour conversion
 >123456 ^[[38;5;24m
 >654321 ^[[38;5;95m






Messages sorted by: Reverse Date, Date, Thread, Author