Fix Heisenbug trying to unset a sometimes-not-set variable.
[automake/plouj.git] / tests / color.test
blob5b51287a6f6217a15f70ba1ac13470ac031fe86e
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 3, 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 cat >>configure.in <<END
33 AC_OUTPUT
34 END
36 cat >Makefile.am <<'END'
37 AUTOMAKE_OPTIONS = color-tests
38 TESTS = $(check_SCRIPTS)
39 check_SCRIPTS = pass fail skip xpass xfail
40 XFAIL_TESTS = xpass xfail
41 END
43 cat >pass <<END
44 #! /bin/sh
45 exit 0
46 END
48 cat >fail <<END
49 #! /bin/sh
50 exit 1
51 END
53 cat >skip <<END
54 #! /bin/sh
55 exit 77
56 END
58 cp fail xfail
59 cp pass xpass
60 chmod +x pass fail skip xpass xfail
62 $ACLOCAL
63 $AUTOMAKE
64 $AUTOCONF
65 ./configure
67 test_color ()
69 grep ": pass" stdout | $FGREP "$grn"
70 grep ": fail" stdout | $FGREP "$red"
71 grep ": xfail" stdout | $FGREP "$lgn"
72 grep ": xpass" stdout | $FGREP "$red"
73 grep ": skip" stdout | $FGREP "$blu"
76 test_no_color ()
78 grep ": pass" stdout | $FGREP "$grn" && exit 1
79 grep ": fail" stdout | $FGREP "$red" && exit 1
80 grep ": xfail" stdout | $FGREP "$lgn" && exit 1
81 grep ": xpass" stdout | $FGREP "$red" && exit 1
82 grep ": skip" stdout | $FGREP "$blu" && exit 1
86 cat >expect-make <<'END'
87 #! /usr/bin/expect -f
88 spawn $env(MAKE) -e check
89 expect eof
90 END
92 unset TESTS || :
94 AM_COLOR_TESTS=always $MAKE -e check >stdout && { cat stdout; exit 1; }
95 cat stdout
96 test_color
98 MAKE=$MAKE expect -f expect-make >stdout || exit 77
99 cat stdout
100 test_color
102 AM_COLOR_TESTS=no MAKE=$MAKE expect -f expect-make >stdout || exit 77
103 cat stdout
104 test_no_color