tests: work around strangeness in MSYS
[automake.git] / tests / parallel-tests-reset-term.test
blob0b3b6d905edfc8f6933177f8415a83f0b3b855bc
1 #! /bin/sh
2 # Copyright (C) 2011 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 # Check that the parallel-tests driver correctly handle overrides of the
18 # TERM variable by either TESTS_ENVIRONMENT and AM_TESTS_ENVIRONMENT.
20 am_parallel_tests=yes
21 . ./defs || Exit 1
23 esc='\e['
25 # Check that grep can parse nonprinting characters.
26 # BSD 'grep' works from a pipe, but not a seekable file.
27 # GNU or BSD 'grep -a' works on files, but is not portable.
28 case `echo "$esc" | $FGREP "$esc"` in
29 "$esc") ;;
30 *) skip_ "$FGREP can't parse nonprinting characters" ;;
31 esac
33 cat >> configure.in << 'END'
34 AC_OUTPUT
35 END
37 cat > Makefile.am << 'END'
38 AM_COLOR_TESTS = always
39 AUTOMAKE_OPTIONS = color-tests
40 TESTS = foobar
41 END
43 cat > foobar << 'END'
44 #!/bin/sh
45 echo "TERM='$TERM'"
46 echo "expected_term='$expected_term'"
47 test x"$TERM" = x"$expected_term"
48 END
49 chmod a+x foobar
51 mkcheck ()
53 if env AM_COLOR_TESTS=always $* $MAKE check > stdout; then
54 rc=0
55 else
56 rc=1
58 cat stdout
59 cat foobar.log
60 cat test-suite.log
61 return $rc
64 $ACLOCAL
65 $AUTOCONF
66 $AUTOMAKE -a
67 ./configure
69 TERM=ansi; export TERM
70 expected_term=dumb; export expected_term
71 mkcheck TESTS_ENVIRONMENT='TERM=dumb'
72 cat stdout | grep "PASS.*foobar" | $FGREP "$esc"
74 TERM=dumb; export TERM
75 expected_term=ansi; export expected_term
76 mkcheck TESTS_ENVIRONMENT='TERM=ansi'
77 cat stdout | $FGREP "$esc" && Exit 1
79 TERM=ansi; export TERM
80 expected_term=dumb; export expected_term
81 mkcheck AM_TESTS_ENVIRONMENT='TERM=dumb'
82 cat stdout | grep "PASS.*foobar" | $FGREP "$esc"
84 TERM=dumb; export TERM
85 expected_term=ansi; export expected_term
86 mkcheck AM_TESTS_ENVIRONMENT='TERM=ansi'
87 cat stdout | $FGREP "$esc" && Exit 1