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