@matheusbsbs / matheus-bagliano / commits / c2116a1783
Fork 0

test-lib: fix TERM to dumb for test repeatability

Dscho noticed that Term::ReadLine (used by send-email) colorized its output for his TERM settings, inside t9001 tests. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Mar 6, 2008 at 19:04 UTC c2116a1783a3d555d41892ae7db0dd0934d4ddf1
1 file changed +17 -7
t/test-lib.sh
+17 -7
@@ -3,12 +3,16 @@
3 # Copyright (c) 2005 Junio C Hamano
4 #
5
6 +# Keep the original TERM for say_color
7 +ORIGINAL_TERM=$TERM
8 +
9 # For repeatability, reset the environment to known value.
10 LANG=C
11 LC_ALL=C
12 PAGER=cat
13 TZ=UTC
11 -export LANG LC_ALL PAGER TZ
14 +TERM=dumb
15 +export LANG LC_ALL PAGER TERM TZ
16 EDITOR=:
17 VISUAL=:
18 unset GIT_EDITOR
@@ -58,12 +62,14 @@ esac
62 # This test checks if command xyzzy does the right thing...
63 # '
64 # . ./test-lib.sh
61 -
62 -[ "x$TERM" != "xdumb" ] &&
63 - [ -t 1 ] &&
64 - tput bold >/dev/null 2>&1 &&
65 - tput setaf 1 >/dev/null 2>&1 &&
66 - tput sgr0 >/dev/null 2>&1 &&
65 +[ "x$ORIGINAL_TERM" != "xdumb" ] && (
66 + TERM=$ORIGINAL_TERM &&
67 + export TERM &&
68 + [ -t 1 ] &&
69 + tput bold >/dev/null 2>&1 &&
70 + tput setaf 1 >/dev/null 2>&1 &&
71 + tput sgr0 >/dev/null 2>&1
72 + ) &&
73 color=t
74
75 while test "$#" -ne 0
@@ -91,6 +97,9 @@ done
97
98 if test -n "$color"; then
99 say_color () {
100 + (
101 + TERM=$ORIGINAL_TERM
102 + export TERM
103 case "$1" in
104 error) tput bold; tput setaf 1;; # bold red
105 skip) tput bold; tput setaf 2;; # bold green
@@ -101,6 +110,7 @@ if test -n "$color"; then
110 shift
111 echo "* $*"
112 tput sgr0
113 + )
114 }
115 else
116 say_color() {