1 Return-Path: <too@guru-group.fi>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 1CA67431FBD
\r
6 for <notmuch@notmuchmail.org>; Sat, 24 Aug 2013 06:31:33 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id b-QCM0JgvVzo for <notmuch@notmuchmail.org>;
\r
16 Sat, 24 Aug 2013 06:31:23 -0700 (PDT)
\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])
\r
18 by olra.theworths.org (Postfix) with ESMTP id C4F20431FDC
\r
19 for <notmuch@notmuchmail.org>; Sat, 24 Aug 2013 06:31:22 -0700 (PDT)
\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)
\r
21 id C2B4710009D; Sat, 24 Aug 2013 16:31:14 +0300 (EEST)
\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
23 To: notmuch@notmuchmail.org
\r
24 Subject: [PATCH 1/1] test: pre-set terminal capabilities (colors, boldness)
\r
25 Date: Sat, 24 Aug 2013 16:31:13 +0300
\r
26 Message-Id: <1377351073-4076-1-git-send-email-tomi.ollila@iki.fi>
\r
27 X-Mailer: git-send-email 1.8.0
\r
28 Cc: tomi.ollila@iki.fi
\r
29 X-BeenThere: notmuch@notmuchmail.org
\r
30 X-Mailman-Version: 2.1.13
\r
32 List-Id: "Use and development of the notmuch mail system."
\r
33 <notmuch.notmuchmail.org>
\r
34 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
35 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
36 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
37 List-Post: <mailto:notmuch@notmuchmail.org>
\r
38 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
39 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
40 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
41 X-List-Received-Date: Sat, 24 Aug 2013 13:31:33 -0000
\r
43 By pre-setting terminal capabilities (colors, boldness) to shell
\r
44 variables we avoid the overhead of running external commands (in
\r
45 separate subshell) each time colored text is printed to screen.
\r
47 test/test-lib.sh | 84 ++++++++++++++++++++++++++++----------------------------
\r
48 1 file changed, 42 insertions(+), 42 deletions(-)
\r
50 diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
51 index ffab1bb..8be2065 100644
\r
52 --- a/test/test-lib.sh
\r
53 +++ b/test/test-lib.sh
\r
54 @@ -38,9 +38,6 @@ done,*)
\r
58 -# Keep the original TERM for say_color and test_emacs
\r
59 -ORIGINAL_TERM=$TERM
\r
61 # dtach(1) provides more capable terminal environment to anything
\r
62 # that requires more than dumb terminal...
\r
63 [ x"${TERM:-dumb}" = xdumb ] && DTACH_TERM=vt100 || DTACH_TERM=$TERM
\r
64 @@ -50,8 +47,49 @@ LANG=C
\r
68 +export LANG LC_ALL PAGER TZ
\r
70 +if [ x"${TERM:-dumb}" != xdumb ]; then
\r
72 + # http://en.wikipedia.org/wiki/Tput
\r
73 + TC_BOLD=`tput bold 2>/dev/null` &&
\r
74 + TC_RED=`tput setaf 1 2>/dev/null` &&
\r
75 + TC_GREEN=`tput setaf 2 2>/dev/null` &&
\r
76 + TC_YELLOW=`tput setaf 3 2>/dev/null` &&
\r
77 + TC_RESET=`tput sgr0 2>/dev/null` ||
\r
83 +if test -n "$TC_BOLD"; then
\r
86 + error) printf '%s%s' "$TC_BOLD" "$TC_RED" ;;
\r
87 + skip) printf '%s%s' "$TC_BOLD" "$TC_GREEN" ;;
\r
88 + pass) printf '%s' "$TC_GREEN" ;;
\r
89 + info) printf '%s' "$TC_YELLOW" ;;
\r
90 + *) test -n "$quiet" && return;;
\r
95 + printf '%s' "$TC_RESET"
\r
100 + test -z "$1" && test -n "$quiet" && return
\r
109 -export LANG LC_ALL PAGER TERM TZ
\r
112 GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}
\r
113 if [[ ( -n "$TEST_EMACS" && -z "$TEST_EMACSCLIENT" ) || \
\r
114 ( -z "$TEST_EMACS" && -n "$TEST_EMACSCLIENT" ) ]]; then
\r
115 @@ -82,15 +120,6 @@ _x32="$_x04$_x04$_x04$_x04$_x04$_x04$_x04$_x04"
\r
116 # This test checks if command xyzzy does the right thing...
\r
119 -[ "x$ORIGINAL_TERM" != "xdumb" ] && (
\r
120 - TERM=$ORIGINAL_TERM &&
\r
123 - tput bold >/dev/null 2>&1 &&
\r
124 - tput setaf 1 >/dev/null 2>&1 &&
\r
125 - tput sgr0 >/dev/null 2>&1
\r
129 while test "$#" -ne 0
\r
131 @@ -136,35 +165,6 @@ else
\r
135 -if test -n "$color"; then
\r
138 - TERM=$ORIGINAL_TERM
\r
141 - error) tput bold; tput setaf 1;; # bold red
\r
142 - skip) tput bold; tput setaf 2;; # bold green
\r
143 - pass) tput setaf 2;; # green
\r
144 - info) tput setaf 3;; # brown
\r
145 - *) test -n "$quiet" && return;;
\r
156 - test -z "$1" && test -n "$quiet" && return
\r
165 say_color error "error: $*\n"
\r