Hash :
a27c9c49
Author :
Date :
2011-05-10T11:30:05
parallel-tests: add auxiliary script 'test-driver', refactor This refactoring should cause no API of functionality change, and is meant only to simplify the future implementation of TAP and SubUnit testsuite drivers. More precisely, our roadmap is to move most of the "testsuite driving" features out of the Automake-generated Makefiles, and into external scripts with well-defined interfaces. This will allow the user to define its own personalized testsuite drivers, and will also offer us a framework upon which to implement our new TAP and SubUnit drivers, all in a very unobtrusive way and retaining an high degree of code reuse and backward-compatibility. * lib/test-driver: New auxiliary script. * lib/Makefile.am (dist_SCRIPT_DATA): Add it. * automake.in (handle_tests): Require the new auxiliary script `test-driver', and define a new internal makefile variable `$(am__test_driver)', used to call it. Perform new substitution on `DRIVER' when processing the `check2.am' file. * lib/check.am (am__tty_colors): Define new shell variable `$am__color_tests'. (am__rst_section): Removed, its role taken over by the new `test-driver' script. (am__test_driver_flags): New variable, contains the command line options passed to `test-driver'. (am__check_pre): Do not deal with temporary files and exit traps anymore, as the `test-driver' script takes care of that now. Define shell variable `$am__enable_hard_errors', used by `$(am__test_driver_flags)'. Reorder so that we don't need to save and restore the value of the `TERM' environment variable anymore. Other related adjustments. (am__check_post): Remove, as its role has been completely taken over by the `test-driver' script. * am/check2.am (?GENERIC?%EXT%$(EXEEXT).log, ?GENERIC?%EXT%.log, ?!GENERIC?%OBJ%): Call the test script through the Automake substituted `%DRIVER%', and honor the command-line options in `$(am__test_driver_flags)'. Do not call the obsoleted `$(am__check_post)' anymore. * doc/automake.texi (Auxiliary Programs): Mention the new `test-driver' script. (Optional): Mention `test-driver' in AC_CONFIG_AUX_DIR. Since we are at it, break the list of auxiliary scripts by placing one per line, to simplify potential future additions of new scripts. * tests/check.test: Adjust. * tests/check2.test : Likewise. * tests/check3.test : Likewise. * tests/check4.test : Likewise. * tests/check10.test: Likewise. * tests/color.test: Likewise. * tests/color2.test: Likewise. * tests/comment9.test: Likewise. * tests/dejagnu.test: Likewise. * tests/exeext4.test: Likewise. * tests/maken3.test: Likewise. * tests/maken4.test: Likewise. * tests/parallel-tests-interrupt.test: Likewise. * tests/posixsubst-tests.test: Likewise. * tests/repeated-options.test: Likewise. * tests/check-no-test-driver.test: New test. * tests/parallel-test-driver-install.test: Likewise. * tests/Makefile.am (TESTS): Update. * NEWS: Update.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
#! /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
## Provide more debugging info.
TEST_LOG_COMPILER = $(SHELL) -x
## Rut required by foo.test; see below.
AM_TESTS_ENVIRONMENT = 9>&2
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 - "$top_testsrcdir"/lib/test-driver > test-driver <<'END'
#!/bin/sh
echo $$ > pid
END
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
./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
# These files shouldn't exist, but in case they do, their content might
# provide helpful information about the causes of the failure(s).
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
: