File: test-curses

package info (click to toggle)
nmh 1.8-4
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 7,860 kB
  • sloc: ansic: 50,445; sh: 22,697; makefile: 1,138; lex: 740; perl: 509; yacc: 265
file content (110 lines) | stat: -rwxr-xr-x 4,062 bytes parent folder | download | duplicates (7)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/sh
#
# Test that the curses function escapes work
#

set -e

if test -z "${MH_OBJ_DIR}"; then
    srcdir=`dirname "$0"`/../..
    MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
fi

. "$MH_OBJ_DIR/test/common.sh"

setup_test
expected="$MH_TEST_DIR/$$.expected"
actual="$MH_TEST_DIR/$$.actual"

require_prog tput

# FreeBSD 9's tput(1) doesn't handle terminfo capabilities, so fall
# back to termcap capability codes.  Its tigetstr(3X) does handle
# them, so the nmh curses support, including etc/scan.curses, works
# just fine.
if tput -Txterm-color sgr0 >/dev/null 2>&1; then
    standout_code=smso
    bold_code=bold
    reset_code=sgr0
    foreground_code=setaf
elif tput -Txterm-color me >/dev/null 2>&1; then
    standout_code=so
    bold_code=md
    reset_code=me
    foreground_code=AF
else
    test_skip "unable to use terminfo or termcap capabilities"
fi

tput -Txterm-color ${reset_code} >/dev/null 2>&1 ||
			test_skip "missing terminfo entry for xterm-color"
tput -Tvt100 ${reset_code} > /dev/null 2>&1 ||
			test_skip "missing terminfo entry for vt100"

#
# Set up things so messages 7-10 are unseen, and message 6 is cur
#

echo "Unseen-Sequence: unseen" >> "$MH"
mark +inbox 7-10 -seq unseen -add
mark 6 -seq cur -add -zero

#
# Right now, in scan.curses cur is marked with standout for monochrome, red
# for color, and unseen is marked with with bold/green for unseen.
#

TERM=vt100; export TERM

standout=`tput ${standout_code}`
bold=`tput ${bold_code}`
reset=`tput ${reset_code}`

cat > "$expected" <<EOF
   1  09/29 Test1              Testing message 1<<This is message number 1 >>${reset}
   2  09/29 Test2              Testing message 2<<This is message number 2 >>${reset}
   3  09/29 Test3              Testing message 3<<This is message number 3 >>${reset}
   4  09/29 Test4              Testing message 4<<This is message number 4 >>${reset}
   5  09/29 Test5              Testing message 5<<This is message number 5 >>${reset}
${standout}   6+ 09/29 Test6              Testing message 6<<This is message number 6 >>${reset}
${bold}   7  09/29 Test7              Testing message 7<<This is message number 7 >>${reset}
${bold}   8  09/29 Test8              Testing message 8<<This is message number 8 >>${reset}
${bold}   9  09/29 Test9              Testing message 9<<This is message number 9 >>${reset}
${bold}  10  09/29 Test10             Testing message 10<<This is message number 10 >>${reset}
EOF

run_prog scan -width 80 -form scan.curses > "$actual"
check "$expected" "$actual"

#
# xterm-color should cause %(hascolor) to return true, so we should execute
# all of the color-based scan output.  According to the terminfo
# documentation the color red should be 1, where green is 2.  But the
# format code will fall back to the older setf capability if setaf isn't
# supported, which has a different color numbering scheme; we should
# test for that at some point.
#

TERM=xterm-color; export TERM

red=`tput ${foreground_code} 1`
green=`tput ${foreground_code} 2`
reset=`tput ${reset_code}`

cat > "$expected" <<EOF
   1  09/29 Test1              Testing message 1<<This is message number 1 >>${reset}
   2  09/29 Test2              Testing message 2<<This is message number 2 >>${reset}
   3  09/29 Test3              Testing message 3<<This is message number 3 >>${reset}
   4  09/29 Test4              Testing message 4<<This is message number 4 >>${reset}
   5  09/29 Test5              Testing message 5<<This is message number 5 >>${reset}
${red}   6+ 09/29 Test6              Testing message 6<<This is message number 6 >>${reset}
${green}   7  09/29 Test7              Testing message 7<<This is message number 7 >>${reset}
${green}   8  09/29 Test8              Testing message 8<<This is message number 8 >>${reset}
${green}   9  09/29 Test9              Testing message 9<<This is message number 9 >>${reset}
${green}  10  09/29 Test10             Testing message 10<<This is message number 10 >>${reset}
EOF

run_prog scan -width 80 -form scan.curses > "$actual"
check "$expected" "$actual"

exit $failed