* tests/parallel-tests-interrupt.test: New test.
* tests/parallel-tests-reset-term.test: Likewise.
* tests/Makefile.am (TESTS): Update.
2011-04-17 Stefano Lattarini <stefano.lattarini@gmail.com>
+ coverage: more tests on the parallel-tests driver
+ * tests/parallel-tests-interrupt.test: New test.
+ * tests/parallel-tests-reset-term.test: Likewise.
+ * tests/Makefile.am (TESTS): Update.
+
+2011-04-17 Stefano Lattarini <stefano.lattarini@gmail.com>
+
check: new developer-reserved AM_TESTS_SETUP variable
For reference, see the discussion at:
<http://lists.gnu.org/archive/html/automake-patches/2011-01/msg00213.html>
parallel-tests-am_tests_setup.test \
parallel-tests-unreadable-log.test \
parallel-tests-subdir.test \
+parallel-tests-interrupt.test \
+parallel-tests-reset-term.test \
parse.test \
percent.test \
percent2.test \
parallel-tests-am_tests_setup.test \
parallel-tests-unreadable-log.test \
parallel-tests-subdir.test \
+parallel-tests-interrupt.test \
+parallel-tests-reset-term.test \
parse.test \
percent.test \
percent2.test \
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Check that the parallel-tests driver removed incomplete log files
+# when interrupt upon some signal. This test is definitely too hacky,
+# but we couldn't find a better way to deal with inter-processes
+# signals and the whole process-synchronization mess.
+
+parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.test
+## Ugly, but required by foo.test. See below.
+TEST_LOG_COMPILER = echo $$$$ > pid && exec 9>&2 && $(SHELL) -x
+END
+
+# This is hacky and ugly, but has the great advantage of avoiding us a lot
+# of pain with background processes and related synchronization issues.
+cat > foo.test << 'END'
+#!/bin/sh
+exec 2>&9
+echo "foo is starting to run"
+ls -l >&2
+cat foo.log-t >&2 || : > fail
+grep '^foo is starting to run$' foo.log-t >&2 || : > fail
+cat pid >&2 || : > fail
+kill -$signum `cat pid` || : > fail
+END
+chmod a+x foo.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+# The only signals that can be trapped portable are 1 "SIGHUP",
+# 2 "SIGINT", 13 "SIGPIPE" and 15 "SIGTERM".
+trapped_signals='1 2 13 15'
+
+for signum in $trapped_signals; do
+ rm -f pid fail *.log *.log-t
+ env signum=$signum $MAKE check && { ls -l; Exit 1; }
+ ls -l
+ cat foo.log-t || :
+ cat foo.log || :
+ cat test-suite.log || :
+ test -f fail && Exit 1
+ test -f foo.log-t && Exit 1
+ test -f foo.log && Exit 1
+done
+
+:
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Check that the parallel-tests driver correctly handle overrides of
+# the TERM variable by either TESTS_ENVIRONMENT and AM_TESTS_SETUP.
+
+parallel_tests=yes
+. ./defs || Exit 1
+
+esc='\e['
+
+# Check that grep can parse nonprinting characters.
+# BSD 'grep' works from a pipe, but not a seekable file.
+# GNU or BSD 'grep -a' works on files, but is not portable.
+case `echo "$esc" | $FGREP "$esc"` in
+ "$esc") ;;
+ *) echo "$me: $FGREP can't parse nonprinting characters" >&2; Exit 77;;
+esac
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AM_COLOR_TESTS = always
+AUTOMAKE_OPTIONS = color-tests
+TESTS = foobar
+END
+
+cat > foobar << 'END'
+#!/bin/sh
+echo "TERM='$TERM'"
+echo "expected_term='$expected_term'"
+test x"$TERM" = x"$expected_term"
+END
+chmod a+x foobar
+
+mkcheck ()
+{
+ if env AM_COLOR_TESTS=always $* $MAKE check > stdout; then
+ rc=0
+ else
+ rc=1
+ fi
+ cat stdout
+ cat foobar.log
+ cat test-suite.log
+ return $rc
+}
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure
+
+TERM=ansi; export TERM
+expected_term=dumb; export expected_term
+mkcheck TESTS_ENVIRONMENT='TERM=dumb'
+cat stdout | grep "PASS.*foobar" | $FGREP "$esc"
+
+TERM=dumb; export TERM
+expected_term=ansi; export expected_term
+mkcheck TESTS_ENVIRONMENT='TERM=ansi'
+cat stdout | $FGREP "$esc" && Exit 1
+
+TERM=ansi; export TERM
+expected_term=dumb; export expected_term
+mkcheck AM_TESTS_SETUP='TERM=dumb'
+cat stdout | grep "PASS.*foobar" | $FGREP "$esc"
+
+TERM=dumb; export TERM
+expected_term=ansi; export expected_term
+mkcheck AM_TESTS_SETUP='TERM=ansi'
+cat stdout | $FGREP "$esc" && Exit 1
+
+: