Skip to content

Commit

Permalink
tests: add color schema to cal(1) tests
Browse files Browse the repository at this point in the history
Signed-off-by: Karel Zak <kzak@redhat.com>
  • Loading branch information
karelzak committed May 23, 2024
1 parent 9abbe9e commit 10ce2af
Show file tree
Hide file tree
Showing 17 changed files with 123 additions and 145 deletions.
16 changes: 8 additions & 8 deletions tests/expected/cal/color-first-day
Original file line number Diff line number Diff line change
@@ -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
16 changes: 8 additions & 8 deletions tests/expected/cal/color-last-day
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions tests/expected/cal/color-reformation-corner-cases-1
Original file line number Diff line number Diff line change
@@ -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



10 changes: 5 additions & 5 deletions tests/expected/cal/color-reformation-corner-cases-2
Original file line number Diff line number Diff line change
@@ -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



10 changes: 5 additions & 5 deletions tests/expected/cal/color-reformation-corner-cases-3
Original file line number Diff line number Diff line change
@@ -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



10 changes: 5 additions & 5 deletions tests/expected/cal/color-reformation-corner-cases-4
Original file line number Diff line number Diff line change
@@ -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



16 changes: 8 additions & 8 deletions tests/expected/cal/color-vertical
Original file line number Diff line number Diff line change
@@ -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
18 changes: 9 additions & 9 deletions tests/expected/cal/color-vertical-week
Original file line number Diff line number Diff line change
@@ -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
16 changes: 8 additions & 8 deletions tests/expected/cal/colorw-first-day-week-numbers
Original file line number Diff line number Diff line change
@@ -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
16 changes: 8 additions & 8 deletions tests/expected/cal/colorw-last-day-week-numbers
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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



Original file line number Diff line number Diff line change
@@ -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



Original file line number Diff line number Diff line change
@@ -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



Original file line number Diff line number Diff line change
@@ -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



47 changes: 15 additions & 32 deletions tests/ts/cal/color
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
37 changes: 13 additions & 24 deletions tests/ts/cal/colorw
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions tests/ts/cal/terminal-colors.d/cal.scheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
workday yellow
weekend red
today \e[48;5;160m\e[38;5;221
header magenta
weeks green
weeknumber blue

0 comments on commit 10ce2af

Please sign in to comment.