53e542c27bc4cac94c53e2ce9a4461fb29e2334e
[platform/upstream/automake.git] / t / parallel-tests-reset-term.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
3 #
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.
8 #
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.
13 #
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/>.
16
17 # Check that the parallel-tests driver correctly handle overrides of the
18 # TERM variable by either TESTS_ENVIRONMENT and AM_TESTS_ENVIRONMENT.
19
20 am_parallel_tests=yes
21 . ./defs || Exit 1
22
23 esc='\e['
24
25 TERM=ansi; export TERM
26
27 # Check that grep can parse nonprinting characters.
28 # BSD 'grep' works from a pipe, but not a seekable file.
29 # GNU or BSD 'grep -a' works on files, but is not portable.
30 case `echo "$esc" | $FGREP "$esc"` in
31   "$esc") ;;
32   *) skip_ "$FGREP can't parse nonprinting characters" ;;
33 esac
34
35 cat >> configure.ac << 'END'
36 AC_OUTPUT
37 END
38
39 cat > Makefile.am << 'END'
40 AM_COLOR_TESTS = always
41 AUTOMAKE_OPTIONS = color-tests
42 TESTS = foobar
43 END
44
45 cat > foobar << 'END'
46 #!/bin/sh
47 echo "TERM='$TERM'"
48 test x"$TERM" = x"dumb"
49 END
50 chmod a+x foobar
51
52 mkcheck ()
53 {
54   if $MAKE "$@" check > stdout; then
55     rc=0
56   else
57     rc=1
58   fi
59   cat stdout
60   cat foobar.log
61   cat test-suite.log
62   return $rc
63 }
64
65 $ACLOCAL
66 $AUTOCONF
67 $AUTOMAKE -a
68 ./configure
69
70 mkcheck TESTS_ENVIRONMENT='TERM=dumb'
71 cat stdout | grep "PASS.*foobar" | $FGREP "$esc"
72
73 mkcheck AM_TESTS_ENVIRONMENT='TERM=dumb'
74 cat stdout | grep "PASS.*foobar" | $FGREP "$esc"
75
76 :