Avoid leaking TEST_LOG_COMPILER in environment of test scripts.
[automake.git] / tests / color.test
bloba5bd063f7e53dce6ca19b0d4ed2901b09790cf32
1 #! /bin/sh
2 # Copyright (C) 2007, 2008 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Test Automake TESTS color output.
19 . ./defs || Exit 1
21 set -e
23 TERM=ansi
24 export TERM
26 red='\e[0;31m'
27 grn='\e[0;32m'
28 lgn='\e[1;32m'
29 blu='\e[1;34m'
30 std='\e[m'
32 # Check that grep can parse nonprinting characters.
33 # BSD 'grep' works from a pipe, but not a seekable file.
34 # GNU or BSD 'grep -a' works on files, but is not portable.
35 case `echo "$std" | grep .` in
36 $std) ;;
37 *) Exit 77 ;;
38 esac
40 cat >>configure.in <<END
41 AC_OUTPUT
42 END
44 cat >Makefile.am <<'END'
45 AUTOMAKE_OPTIONS = color-tests
46 TESTS = $(check_SCRIPTS)
47 check_SCRIPTS = pass fail skip xpass xfail
48 XFAIL_TESTS = xpass xfail
49 END
51 cat >pass <<END
52 #! /bin/sh
53 exit 0
54 END
56 cat >fail <<END
57 #! /bin/sh
58 exit 1
59 END
61 cat >skip <<END
62 #! /bin/sh
63 exit 77
64 END
66 cp fail xfail
67 cp pass xpass
68 chmod +x pass fail skip xpass xfail
70 $ACLOCAL
71 $AUTOMAKE
72 $AUTOCONF
73 ./configure
75 test_color ()
77 # Not a useless use of cat; see above comments about grep.
78 cat stdout | grep ": pass" | $FGREP "$grn"
79 cat stdout | grep ": fail" | $FGREP "$red"
80 cat stdout | grep ": xfail" | $FGREP "$lgn"
81 cat stdout | grep ": xpass" | $FGREP "$red"
82 cat stdout | grep ": skip" | $FGREP "$blu"
85 test_no_color ()
87 # Not a useless use of cat; see above comments about grep.
88 cat stdout | grep ": pass" | $FGREP "$grn" && Exit 1
89 cat stdout | grep ": fail" | $FGREP "$red" && Exit 1
90 cat stdout | grep ": xfail" | $FGREP "$lgn" && Exit 1
91 cat stdout | grep ": xpass" | $FGREP "$red" && Exit 1
92 cat stdout | grep ": skip" | $FGREP "$blu" && Exit 1
96 cat >expect-make <<'END'
97 #! /usr/bin/expect -f
98 spawn $env(MAKE) -e check
99 expect eof
102 unset TESTS || :
104 AM_COLOR_TESTS=always $MAKE -e check >stdout && { cat stdout; Exit 1; }
105 cat stdout
106 test_color
108 MAKE=$MAKE expect -f expect-make >stdout || { cat stdout; Exit 77; }
109 cat stdout
110 test_color
112 AM_COLOR_TESTS=no MAKE=$MAKE expect -f expect-make >stdout || { cat stdout; Exit 77; }
113 cat stdout
114 test_no_color