From: Karel Zak Date: Thu, 23 May 2024 11:13:34 +0000 (+0200) Subject: tests: add color schema to cal(1) tests X-Git-Tag: v2.42-start~319^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10ce2af422fc2465a6d5210a4f616b1b8d8ee3d3;p=thirdparty%2Futil-linux.git tests: add color schema to cal(1) tests Signed-off-by: Karel Zak --- diff --git a/tests/expected/cal/color-first-day b/tests/expected/cal/color-first-day index 446f4fd93e..229681d6aa 100644 --- a/tests/expected/cal/color-first-day +++ b/tests/expected/cal/color-first-day @@ -1,8 +1,8 @@ - January 0001 -Su Mo Tu We Th Fr Sa -  1 - 2 3 4 5 6 7 8 - 9 10 11 12 13 14 15 -16 17 18 19 20 21 22 -23 24 25 26 27 28 29 -30 31 + January 0001 +Su Mo Tu We Th Fr Sa +  [ 1 + 2 3 4 5 6 7 8 + 9 10 11 12 13 14 15 +16 17 18 19 20 21 22 +23 24 25 26 27 28 29 +30 31 diff --git a/tests/expected/cal/color-last-day b/tests/expected/cal/color-last-day index ec7793c6b5..b7020ab3ff 100644 --- a/tests/expected/cal/color-last-day +++ b/tests/expected/cal/color-last-day @@ -1,8 +1,8 @@ - November 9999 December 9999 January 10000 -Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa - 1 2 3 4 5 6 1 2 3 4 1 - 7 8 9 10 11 12 13 5 6 7 8 9 10 11 2 3 4 5 6 7 8 -14 15 16 17 18 19 20 12 13 14 15 16 17 18 9 10 11 12 13 14 15 -21 22 23 24 25 26 27 19 20 21 22 23 24 25 16 17 18 19 20 21 22 -28 29 30 26 27 28 29 30 31 23 24 25 26 27 28 29 - 30 31 + November 9999 December 9999 January 10000 +Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa +  1 2 3 4 5 6  1 2 3 4  1 + 7 8 9 10 11 12 13  5 6 7 8 9 10 11  2 3 4 5 6 7 8 +14 15 16 17 18 19 20 12 13 14 15 16 17 18  9 10 11 12 13 14 15 +21 22 23 24 25 26 27 19 20 21 22 23 24 25 16 17 18 19 20 21 22 +28 29 30 26 27 28 29 30 [31 23 24 25 26 27 28 29 + 30 31 diff --git a/tests/expected/cal/color-reformation-corner-cases-1 b/tests/expected/cal/color-reformation-corner-cases-1 index 4b26465bbe..af9e2bd81a 100644 --- a/tests/expected/cal/color-reformation-corner-cases-1 +++ b/tests/expected/cal/color-reformation-corner-cases-1 @@ -1,8 +1,8 @@ - September 1752 -Su Mo Tu We Th Fr Sa - 1  2 14 15 16 -17 18 19 20 21 22 23 -24 25 26 27 28 29 30 + September 1752 +Su Mo Tu We Th Fr Sa +  1 [ 2 14 15 16 +17 18 19 20 21 22 23 +24 25 26 27 28 29 30 diff --git a/tests/expected/cal/color-reformation-corner-cases-2 b/tests/expected/cal/color-reformation-corner-cases-2 index db29a7f424..75402e99a9 100644 --- a/tests/expected/cal/color-reformation-corner-cases-2 +++ b/tests/expected/cal/color-reformation-corner-cases-2 @@ -1,8 +1,8 @@ - September 1752 -Su Mo Tu We Th Fr Sa - 1 2 14 15 16 -17 18 19 20 21 22 23 -24 25 26 27 28 29 30 + September 1752 +Su Mo Tu We Th Fr Sa +  1 2 14 15 16 +17 18 19 20 21 22 23 +24 25 26 27 28 29 30 diff --git a/tests/expected/cal/color-reformation-corner-cases-3 b/tests/expected/cal/color-reformation-corner-cases-3 index db29a7f424..75402e99a9 100644 --- a/tests/expected/cal/color-reformation-corner-cases-3 +++ b/tests/expected/cal/color-reformation-corner-cases-3 @@ -1,8 +1,8 @@ - September 1752 -Su Mo Tu We Th Fr Sa - 1 2 14 15 16 -17 18 19 20 21 22 23 -24 25 26 27 28 29 30 + September 1752 +Su Mo Tu We Th Fr Sa +  1 2 14 15 16 +17 18 19 20 21 22 23 +24 25 26 27 28 29 30 diff --git a/tests/expected/cal/color-reformation-corner-cases-4 b/tests/expected/cal/color-reformation-corner-cases-4 index 6c5571458e..dbf47a9085 100644 --- a/tests/expected/cal/color-reformation-corner-cases-4 +++ b/tests/expected/cal/color-reformation-corner-cases-4 @@ -1,8 +1,8 @@ - September 1752 -Su Mo Tu We Th Fr Sa - 1 2 14 15 16 -17 18 19 20 21 22 23 -24 25 26 27 28 29 30 + September 1752 +Su Mo Tu We Th Fr Sa +  1 2 [14 15 16 +17 18 19 20 21 22 23 +24 25 26 27 28 29 30 diff --git a/tests/expected/cal/color-vertical b/tests/expected/cal/color-vertical index bf5c609413..f4ffac6a5d 100644 --- a/tests/expected/cal/color-vertical +++ b/tests/expected/cal/color-vertical @@ -1,8 +1,8 @@ - February 2023 -Su 5 12 19 26 -Mo 6 13 20 27 -Tu 7 14 21 28 -We 1 8 15 22 -Th 2 9 16 23 -Fr 3 10 17 24 -Sa 4 11 18 25 + February 2023  +Su  5 12 19 26 +Mo  6 13 20 27 +Tu  7 14 21 28 +We 1 8 [15 22 +Th 2 9 16 23 +Fr 3 10 17 24 +Sa 4 11 18 25 diff --git a/tests/expected/cal/color-vertical-week b/tests/expected/cal/color-vertical-week index d69866e1f1..7060361853 100644 --- a/tests/expected/cal/color-vertical-week +++ b/tests/expected/cal/color-vertical-week @@ -1,9 +1,9 @@ - February 2023 -Su 5 12 19 26 -Mo 6 13 20 27 -Tu 7 14 21 28 -We 1 8 15 22 -Th 2 9 16 23 -Fr 3 10 17 24 -Sa 4 11 18 25 - 5 6 7 8 9 + February 2023  +Su  5 12 19 26 +Mo  6 13 20 27 +Tu  7 14 21 28 +We 1 8 [15 22 +Th 2 9 16 23 +Fr 3 10 17 24 +Sa 4 11 18 25 +  5  6  7  8  9 diff --git a/tests/expected/cal/colorw-first-day-week-numbers b/tests/expected/cal/colorw-first-day-week-numbers index e14aaf3a39..f3117d89b2 100644 --- a/tests/expected/cal/colorw-first-day-week-numbers +++ b/tests/expected/cal/colorw-first-day-week-numbers @@ -1,8 +1,8 @@ - January 0001 - Su Mo Tu We Th Fr Sa - 1  1 - 2 2 3 4 5 6 7 8 - 3 9 10 11 12 13 14 15 - 4 16 17 18 19 20 21 22 - 5 23 24 25 26 27 28 29 - 6 30 31 + January 0001 + Su Mo Tu We Th Fr Sa + 1  [ 1 + 2 2 3 4 5 6 7 8 + 3 9 10 11 12 13 14 15 + 4 16 17 18 19 20 21 22 + 5 23 24 25 26 27 28 29 + 6 30 31 diff --git a/tests/expected/cal/colorw-last-day-week-numbers b/tests/expected/cal/colorw-last-day-week-numbers index d0d49cc292..dd081fdfc6 100644 --- a/tests/expected/cal/colorw-last-day-week-numbers +++ b/tests/expected/cal/colorw-last-day-week-numbers @@ -1,8 +1,8 @@ - November 9999 December 9999 January 10000 - Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa -45 1 2 3 4 5 6 49 1 2 3 4 1 1 -46 7 8 9 10 11 12 13 50 5 6 7 8 9 10 11 2 2 3 4 5 6 7 8 -47 14 15 16 17 18 19 20 51 12 13 14 15 16 17 18 3 9 10 11 12 13 14 15 -48 21 22 23 24 25 26 27 52 19 20 21 22 23 24 25 4 16 17 18 19 20 21 22 -49 28 29 30 53 26 27 28 29 30 31 5 23 24 25 26 27 28 29 - 6 30 31 + November 9999 December 9999 January 10000 + Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa +45  1 2 3 4 5 6 49  1 2 3 4  1  1 +46 7 8 9 10 11 12 13 50 5 6 7 8 9 10 11  2 2 3 4 5 6 7 8 +47 14 15 16 17 18 19 20 51 12 13 14 15 16 17 18  3 9 10 11 12 13 14 15 +48 21 22 23 24 25 26 27 52 19 20 21 22 23 24 25  4 16 17 18 19 20 21 22 +49 28 29 30 53 26 27 28 29 30 [31  5 23 24 25 26 27 28 29 +  6 30 31 diff --git a/tests/expected/cal/colorw-reformation-corner-cases-1-week-numbers b/tests/expected/cal/colorw-reformation-corner-cases-1-week-numbers index 98fa041f68..a94a28e549 100644 --- a/tests/expected/cal/colorw-reformation-corner-cases-1-week-numbers +++ b/tests/expected/cal/colorw-reformation-corner-cases-1-week-numbers @@ -1,8 +1,8 @@ - September 1752 - Su Mo Tu We Th Fr Sa -36 1  2 14 15 16 -37 17 18 19 20 21 22 23 -38 24 25 26 27 28 29 30 + September 1752 + Su Mo Tu We Th Fr Sa +36  1 [ 2 14 15 16 +37 17 18 19 20 21 22 23 +38 24 25 26 27 28 29 30 diff --git a/tests/expected/cal/colorw-reformation-corner-cases-2-week-numbers b/tests/expected/cal/colorw-reformation-corner-cases-2-week-numbers index fdbc199703..701eb91fe8 100644 --- a/tests/expected/cal/colorw-reformation-corner-cases-2-week-numbers +++ b/tests/expected/cal/colorw-reformation-corner-cases-2-week-numbers @@ -1,8 +1,8 @@ - September 1752 - Su Mo Tu We Th Fr Sa -36 1 2 14 15 16 -37 17 18 19 20 21 22 23 -38 24 25 26 27 28 29 30 + September 1752 + Su Mo Tu We Th Fr Sa +36  1 2 14 15 16 +37 17 18 19 20 21 22 23 +38 24 25 26 27 28 29 30 diff --git a/tests/expected/cal/colorw-reformation-corner-cases-3-week-numbers b/tests/expected/cal/colorw-reformation-corner-cases-3-week-numbers index fdbc199703..701eb91fe8 100644 --- a/tests/expected/cal/colorw-reformation-corner-cases-3-week-numbers +++ b/tests/expected/cal/colorw-reformation-corner-cases-3-week-numbers @@ -1,8 +1,8 @@ - September 1752 - Su Mo Tu We Th Fr Sa -36 1 2 14 15 16 -37 17 18 19 20 21 22 23 -38 24 25 26 27 28 29 30 + September 1752 + Su Mo Tu We Th Fr Sa +36  1 2 14 15 16 +37 17 18 19 20 21 22 23 +38 24 25 26 27 28 29 30 diff --git a/tests/expected/cal/colorw-reformation-corner-cases-4-week-numbers b/tests/expected/cal/colorw-reformation-corner-cases-4-week-numbers index 307b5398e5..e35901a0f3 100644 --- a/tests/expected/cal/colorw-reformation-corner-cases-4-week-numbers +++ b/tests/expected/cal/colorw-reformation-corner-cases-4-week-numbers @@ -1,8 +1,8 @@ - September 1752 - Su Mo Tu We Th Fr Sa -36 1 2 14 15 16 -37 17 18 19 20 21 22 23 -38 24 25 26 27 28 29 30 + September 1752 + Su Mo Tu We Th Fr Sa +36  1 2 [14 15 16 +37 17 18 19 20 21 22 23 +38 24 25 26 27 28 29 30 diff --git a/tests/ts/cal/color b/tests/ts/cal/color index 90840ea4d5..2dffefed38 100755 --- a/tests/ts/cal/color +++ b/tests/ts/cal/color @@ -31,64 +31,47 @@ fi # --color output depends on terminal type export TERM=linux +function call_cal { + if [ "$USETERM" == "yes" ]; then + XDG_CONFIG_HOME="$TS_SELF" $TS_CMD_CAL --color=always "$@" + fi + XDG_CONFIG_HOME="$TS_SELF" $TS_CMD_CAL --color=always "$@" >> $TS_OUTPUT +} + USETERM=$( ts_has_option "useterm" "$*" ) [ "$USETERM" == "yes" ] && TS_VERBOSE="yes" ts_init_subtest "first-day" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL --color=always 1 1 1 -fi -$TS_CMD_CAL --color=always 1 1 1 >> $TS_OUTPUT +call_cal --color=always 1 1 1 ts_finalize_subtest ts_init_subtest "reformation-corner-cases-1" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL --color=always 2 9 1752 -fi -$TS_CMD_CAL --color=always 2 9 1752 >> $TS_OUTPUT +call_cal --color=always 2 9 1752 ts_finalize_subtest ts_init_subtest "reformation-corner-cases-2" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL --color=always 3 9 1752 -fi -$TS_CMD_CAL --color=always 3 9 1752 >> $TS_OUTPUT +call_cal --color=always 3 9 1752 ts_finalize_subtest ts_init_subtest "reformation-corner-cases-3" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL --color=always 13 9 1752 -fi -$TS_CMD_CAL --color=always 13 9 1752 >> $TS_OUTPUT +call_cal --color=always 13 9 1752 ts_finalize_subtest ts_init_subtest "reformation-corner-cases-4" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL --color=always 14 9 1752 -fi -$TS_CMD_CAL --color=always 14 9 1752 >> $TS_OUTPUT +call_cal --color=always 14 9 1752 ts_finalize_subtest ts_init_subtest "last-day" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL --color=always 31 12 9999 -fi -$TS_CMD_CAL --color=always -3 31 12 9999 >> $TS_OUTPUT +call_cal --color=always -3 31 12 9999 ts_finalize_subtest ts_init_subtest "vertical" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL --color=always 15 2 2023 -fi -$TS_CMD_CAL --color=always --vertical 15 2 2023 >> $TS_OUTPUT +call_cal --color=always --vertical 15 2 2023 ts_finalize_subtest ts_init_subtest "vertical-week" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL --color=always 15 2 2023 -fi -$TS_CMD_CAL --color=always --vertical --week=15 15 2 2023 >> $TS_OUTPUT +call_cal --color=always --vertical --week=15 15 2 2023 ts_finalize_subtest diff --git a/tests/ts/cal/colorw b/tests/ts/cal/colorw index 96e6e0a34a..541e2f4454 100755 --- a/tests/ts/cal/colorw +++ b/tests/ts/cal/colorw @@ -35,46 +35,35 @@ USETERM=$( ts_has_option "useterm" "$*" ) [ "$USETERM" == "yes" ] && TS_VERBOSE="yes" +function call_cal { + if [ "$USETERM" == "yes" ]; then + XDG_CONFIG_HOME="$TS_SELF" $TS_CMD_CAL --color=always "$@" + fi + XDG_CONFIG_HOME="$TS_SELF" $TS_CMD_CAL --color=always "$@" >> $TS_OUTPUT +} + ts_init_subtest "first-day-week-numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -w --color=always 1 1 1 -fi -$TS_CMD_CAL -w --color=always 1 1 1 >> $TS_OUTPUT +call_cal -w --color=always 1 1 1 ts_finalize_subtest ts_init_subtest "reformation-corner-cases-1-week-numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -w --color=always 2 9 1752 -fi -$TS_CMD_CAL -w --color=always 2 9 1752 >> $TS_OUTPUT +call_cal -w --color=always 2 9 1752 ts_finalize_subtest ts_init_subtest "reformation-corner-cases-2-week-numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -w --color=always 3 9 1752 -fi -$TS_CMD_CAL -w --color=always 3 9 1752 >> $TS_OUTPUT +call_cal -w --color=always 3 9 1752 ts_finalize_subtest ts_init_subtest "reformation-corner-cases-3-week-numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -w --color=always 13 9 1752 -fi -$TS_CMD_CAL -w --color=always 13 9 1752 >> $TS_OUTPUT +call_cal -w --color=always 13 9 1752 ts_finalize_subtest ts_init_subtest "reformation-corner-cases-4-week-numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -w --color=always 14 9 1752 -fi -$TS_CMD_CAL -w --color=always 14 9 1752 >> $TS_OUTPUT +call_cal -w --color=always 14 9 1752 ts_finalize_subtest ts_init_subtest "last-day-week-numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -w --color=always 31 12 9999 -fi -$TS_CMD_CAL -w --color=always -3 31 12 9999 >> $TS_OUTPUT +call_cal -w --color=always -3 31 12 9999 ts_finalize_subtest ts_finalize diff --git a/tests/ts/cal/terminal-colors.d/cal.scheme b/tests/ts/cal/terminal-colors.d/cal.scheme new file mode 100644 index 0000000000..4f959622fe --- /dev/null +++ b/tests/ts/cal/terminal-colors.d/cal.scheme @@ -0,0 +1,6 @@ +workday yellow +weekend red +today \e[48;5;160m\e[38;5;221 +header magenta +weeks green +weeknumber blue