From: Ken Hornstein Date: Mon, 6 Jan 2014 16:20:47 +0000 (-0500) Subject: Add a test for the new curses-based format escapes. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/8884d1baae25b585efbb3c34515a2d1a198ba847?ds=sidebyside Add a test for the new curses-based format escapes. --- diff --git a/Makefile.am b/Makefile.am index d926e551..1e159feb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -51,6 +51,7 @@ TESTS = test/ali/test-ali test/anno/test-anno \ test/folder/test-create test/folder/test-packf \ test/folder/test-recurse test/folder/test-sortm \ test/folder/test-total \ + test/format/test-curses \ test/format/test-dp test/format/test-fmtdump \ test/format/test-localmbox test/format/test-myname \ test/format/test-myhost test/format/test-mymbox \ diff --git a/test/common.sh.in b/test/common.sh.in index dabe6c54..13db440a 100644 --- a/test/common.sh.in +++ b/test/common.sh.in @@ -280,8 +280,8 @@ EOF for f in MailAliases components digestcomps distcomps forwcomps mhl.body \ mhl.digest mhl.format mhl.forward mhl.headers mhl.reply \ mhn.defaults rcvdistcomps replcomps replgroupcomps scan.MMDDYY \ - scan.YYYYMMDD scan.default scan.highlighted scan.mailx scan.nomime \ - scan.size scan.time scan.timely scan.unseen + scan.YYYYMMDD scan.curses scan.default scan.highlighted scan.mailx \ + scan.nomime scan.size scan.time scan.timely scan.unseen do cp "${MH_INST_DIR}${sysconfdir}/${f}" "${MH_TEST_DIR}/Mail" || exit 1 done diff --git a/test/format/test-curses b/test/format/test-curses new file mode 100755 index 00000000..b85bd8f8 --- /dev/null +++ b/test/format/test-curses @@ -0,0 +1,92 @@ +#!/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 + +tput -Txterm-color sgr0 >/dev/null 2>&1 || + test_skip "missing terminfo entry for xterm-color" +tput -Tvt100 sgr0 > /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 smso` +bold=`tput bold` +reset=`tput sgr0` + +cat > "$expected" <>${reset} + 2 09/29 Test2 Testing message 2<>${reset} + 3 09/29 Test3 Testing message 3<>${reset} + 4 09/29 Test4 Testing message 4<>${reset} + 5 09/29 Test5 Testing message 5<>${reset} +${standout} 6+ 09/29 Test6 Testing message 6<>${reset} +${bold} 7 09/29 Test7 Testing message 7<>${reset} +${bold} 8 09/29 Test8 Testing message 8<>${reset} +${bold} 9 09/29 Test9 Testing message 9<>${reset} +${bold} 10 09/29 Test10 Testing message 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 setaf 1` +green=`tput setaf 2` +reset=`tput sgr0` + +cat > "$expected" <>${reset} + 2 09/29 Test2 Testing message 2<>${reset} + 3 09/29 Test3 Testing message 3<>${reset} + 4 09/29 Test4 Testing message 4<>${reset} + 5 09/29 Test5 Testing message 5<>${reset} +${red} 6+ 09/29 Test6 Testing message 6<>${reset} +${green} 7 09/29 Test7 Testing message 7<>${reset} +${green} 8 09/29 Test8 Testing message 8<>${reset} +${green} 9 09/29 Test9 Testing message 9<>${reset} +${green} 10 09/29 Test10 Testing message 10<>${reset} +EOF + +run_prog scan -width 80 -form scan.curses > "$actual" +check "$expected" "$actual" + +exit $failed