summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoritchyny <itchyny@cybozu.co.jp>2023-07-12 09:31:26 +0900
committerNico Williams <nico@cryptonector.com>2023-07-18 17:53:29 -0500
commit0b558f6ed498717546406b5367483b976578a9b2 (patch)
tree780d3eb3a27ec66aa5c26b495682ef1a5c737e44 /tests
parent62d65a8a9ca181fcade36260814f8a14c442467a (diff)
Make object key color configurable (close #1739, #1791, #2638)
Co-authored-by: David Haguenauer <ml@kurokatta.org> Co-authored-by: Eric Pruitt <eric.pruitt@gmail.com>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/shtest58
1 files changed, 42 insertions, 16 deletions
diff --git a/tests/shtest b/tests/shtest
index a7fba445..0a0ddcf7 100755
--- a/tests/shtest
+++ b/tests/shtest
@@ -335,29 +335,55 @@ if [ "$($VALGRIND $Q $JQ -n '{"a":"xyz"} | halt_error(1)' 2>&1)" != '{"a":"xyz"}
fi
# Check $JQ_COLORS
+unset JQ_COLORS
+
+## Default colors, null input
$JQ -Ccn . > $d/color
printf '\033[1;30mnull\033[0m\n' > $d/expect
cmp $d/color $d/expect
+
+## Set non-default color, null input
JQ_COLORS='4;31' $JQ -Ccn . > $d/color
printf '\033[4;31mnull\033[0m\n' > $d/expect
cmp $d/color $d/expect
-JQ_COLORS='1;30:0;31:0;32:0;33:0;34:1;35:1;36' \
+
+## Default colors, complex input
+$JQ -Ccn '[{"a":true,"b":false},123,null]' > $d/color
+{
+ printf '\033[1;37m[\033[1;37m{'
+ printf '\033[0m\033[1;34m"a"\033['
+ printf '0m\033[1;37m:\033[0m\033['
+ printf '0;37mtrue\033[0m\033[1'
+ printf ';37m,\033[0m\033[1;34m'
+ printf '"b"\033[0m\033[1;37m:\033'
+ printf '[0m\033[0;37mfalse\033'
+ printf '[0m\033[1;37m\033[1;37'
+ printf 'm}\033[0m\033[1;37m,\033['
+ printf '0;37m123\033[0m\033[1;'
+ printf '37m,\033[1;30mnull\033'
+ printf '[0m\033[1;37m\033[1;37'
+ printf 'm]\033[0m\n'
+} > $d/expect
+cmp $d/color $d/expect
+
+## Set non-default colors, complex input
+JQ_COLORS='1;30:0;31:0;32:0;33:0;34:1;35:1;36:1;30' \
$JQ -Ccn '[{"a":true,"b":false},123,null]' > $d/color
-(
-printf '\033[1;35m[\033[1;36m{'
-printf '\033[0m\033[34;1m"a"\033['
-printf '0m\033[1;36m:\033[0m\033['
-printf '0;32mtrue\033[0m\033[1'
-printf ';36m,\033[0m\033[34;1m'
-printf '"b"\033[0m\033[1;36m:\033'
-printf '[0m\033[0;31mfalse\033'
-printf '[0m\033[1;36m\033[1;36'
-printf 'm}\033[0m\033[1;35m,\033['
-printf '0;33m123\033[0m\033[1;'
-printf '35m,\033[1;30mnull\033'
-printf '[0m\033[1;35m\033[1;35'
-printf 'm]\033[0m\n'
-) > $d/expect
+{
+ printf '\033[1;35m[\033[1;36m{'
+ printf '\033[0m\033[1;30m"a"\033['
+ printf '0m\033[1;36m:\033[0m\033['
+ printf '0;32mtrue\033[0m\033[1'
+ printf ';36m,\033[0m\033[1;30m'
+ printf '"b"\033[0m\033[1;36m:\033'
+ printf '[0m\033[0;31mfalse\033'
+ printf '[0m\033[1;36m\033[1;36'
+ printf 'm}\033[0m\033[1;35m,\033['
+ printf '0;33m123\033[0m\033[1;'
+ printf '35m,\033[1;30mnull\033'
+ printf '[0m\033[1;35m\033[1;35'
+ printf 'm]\033[0m\n'
+} > $d/expect
cmp $d/color $d/expect
# Check garbage in JQ_COLORS. We write each color sequence into a 16