+2011-08-17 Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ tap: add a dummy TAP driver script implemented in shell + awk
+ The user can also now decide which implementation of the TAP driver
+ to use in the testsuite by defining the `$am_tap_implementation'
+ variable to either "perl" or "shell". Future enhancements will
+ allow the testsuite to automatically run the test scripts on TAP
+ support with both the TAP driver implementations, to improve
+ coverage.
+ * tests/defs (fetch_tap_driver): Honor the `$am_tap_implementation'
+ variable to decide which implementation of the TAP driver to fetch.
+ ($am_tap_implementation): Default to "perl".
+ * tests/tap-common-setup.test: Do not fetch the TAP driver, the
+ code in tap-setup.sh does that already (and respecting runtime
+ overriding of `$am_tap_implementation').
+ * lib/tap-driver: Renamed ...
+ * lib/tap-driver.pl: ... to this, and ...
+ ($ME): ... adjusted this.
+ * doc/automake.texi: Adjust to the renaming.
+ * tests/Makefile.am (TAP_LOG_DRIVER): Likewise.
+ * tests/tap-doc2.test: Likewise.
+ * lib/tap-driver.sh: New script, still mostly dummy.
+ * lib/Makefile.am (dist_script_DATA): Update, and since we are at
+ it, rewrite it to make it easier to add new entries in the future.
+
2011-08-17 Stefano Lattarini <stefano.lattarini@gmail.com>
testsuite: refactor tests on TAP support in view of future changes
Currently, the TAP driver that comes with Automake requires a perl
interpreter to work, and requires various by-hand steps on the
developer's part (this should be fixed in future Automake versions).
-You'll have grab the @file{tap-driver} script from the Automake
+You'll have grab the @file{tap-driver.pl} script from the Automake
distribution by hand, copy it in your source tree, add code to
@file{configure.ac} to search a perl interpreter and to define the
@code{$(PERL)} variable accordingly, and use the Automake support
for third-party test drivers to instruct the harness to use the
-@file{tap-driver} to run your TAP-producing tests. See the example
+@file{tap-driver.pl} to run your TAP-producing tests. See the example
below for clarification.
Apart from the options common to all the Automake test drivers
-(@pxref{Command-line arguments for test drivers}), the @file{tap-driver}
+(@pxref{Command-line arguments for test drivers}), the @file{tap-driver.pl}
supports the following options, whose names are chosen for enhanced
compatibility with the @command{prove} utility.
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([foreign parallel-tests -Wall -Werror])
AC_CONFIG_FILES([Makefile])
-AC_REQUIRE_AUX_FILE([tap-driver])
+AC_REQUIRE_AUX_FILE([tap-driver.pl])
AC_PATH_PROG([PERL], [perl])
test -n "$PERL" || AC_MSG_ERROR([perl not found])
$PERL -MTAP::Parser -e 1 || AC_MSG_ERROR([TAP::Parser not found])
AC_OUTPUT
% @kbd{cat Makefile.am}
-TEST_LOG_DRIVER = $(PERL) $(srcdir)/build-aux/tap-driver
+TEST_LOG_DRIVER = $(PERL) $(srcdir)/build-aux/tap-driver.pl
TESTS = foo.test bar.test baz.test
EXTRA_DIST = $(TESTS)
# Exit with error, even if all the test case has been successful.
exit 7
-% @kbd{cp @var{PREFIX}/share/automake-@var{APIVERSION}/tap-driver .}
+% @kbd{cp @var{PREFIX}/share/automake-@var{APIVERSION}/tap-driver.pl .}
% @kbd{autoreconf -vi && ./configure && make check}
...
PASS: foo.test 1 - Swallows fly
## Makefile for Automake lib.
-# Copyright (C) 2001, 2003, 2004, 2009, 2010 Free Software Foundation,
-# Inc.
+# Copyright (C) 2001, 2003, 2004, 2009, 2010, 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
## _SCRIPTS, then the program transform will be applied, which is not
## what we want. So we make them executable by hand.
scriptdir = $(pkgvdatadir)
-dist_script_DATA = config.guess config.sub install-sh mdate-sh missing \
- mkinstalldirs elisp-comp ylwrap acinstall depcomp compile py-compile \
- symlink-tree ar-lib test-driver tap-driver
+dist_script_DATA = \
+ config.guess \
+ config.sub \
+ install-sh \
+ mdate-sh \
+ missing \
+ mkinstalldirs \
+ elisp-comp \
+ ylwrap \
+ acinstall \
+ depcomp \
+ compile \
+ py-compile \
+ symlink-tree \
+ ar-lib \
+ test-driver \
+ tap-driver.sh \
+ tap-driver.pl
EXTRA_DIST = gnupload
@SET_MAKE@
-# Copyright (C) 2001, 2003, 2004, 2009, 2010 Free Software Foundation,
-# Inc.
+# Copyright (C) 2001, 2003, 2004, 2009, 2010, 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
config-ml.in
scriptdir = $(pkgvdatadir)
-dist_script_DATA = config.guess config.sub install-sh mdate-sh missing \
- mkinstalldirs elisp-comp ylwrap acinstall depcomp compile py-compile \
- symlink-tree ar-lib test-driver tap-driver
+dist_script_DATA = \
+ config.guess \
+ config.sub \
+ install-sh \
+ mdate-sh \
+ missing \
+ mkinstalldirs \
+ elisp-comp \
+ ylwrap \
+ acinstall \
+ depcomp \
+ compile \
+ py-compile \
+ symlink-tree \
+ ar-lib \
+ test-driver \
+ tap-driver.sh \
+ tap-driver.pl
EXTRA_DIST = gnupload
all: all-recursive
use Getopt::Long ();
use TAP::Parser;
-my $ME = "tap-driver";
+my $ME = "tap-driver.pl";
my $USAGE = <<'END';
Usage:
--- /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/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+scriptversion=2011-08-17.14; # UTC
+
+# Make unconditional expansion of undefined variables an error. This
+# helps a lot in preventing typo-related bugs.
+set -u
+
+fatal ()
+{
+ echo "$0: fatal: $*" >&2
+ exit 1
+}
+
+usage_error ()
+{
+ echo "$0: $*" >&2
+ print_usage >&2
+ exit 2
+}
+
+print_usage ()
+{
+ cat <<END
+Usage:
+ tap-driver --test-name=NAME --log-file=PATH --trs-file=PATH
+ [--expect-failure={yes|no}] [--color-tests={yes|no}]
+ [--enable-hard-errors={yes|no}] [--ignore-exit]
+ [--diagnostic-string=STRING] [--merge|--no-merge]
+ [--comments|--no-comments] [--] TEST-COMMAND
+The \`--test-name' and \`--log-file' options are mandatory.
+END
+}
+
+# TODO: better error handling in option parsing (in particular, ensure
+# TODO: $log_file, $trs_file and $test_name are defined).
+test_name= # Used for reporting.
+log_file= # Where to save the result and output of the test script.
+trs_file= # Where to save the metadata of the test run.
+expect_failure=no
+color_tests=no
+merge=no
+ignore_exit=no
+comments=no
+diag_string='#'
+while test $# -gt 0; do
+ case $1 in
+ --help) print_usage; exit $?;;
+ --version) echo "tap-driver $scriptversion"; exit $?;;
+ --test-name) test_name=$2; shift;;
+ --log-file) log_file=$2; shift;;
+ --trs-file) trs_file=$2; shift;;
+ --color-tests) color_tests=$2; shift;;
+ --expect-failure) expect_failure=$2; shift;;
+ --enable-hard-errors) shift;; # No-op.
+ --merge) merge=yes;;
+ --no-merge) merge=no;;
+ --ignore-exit) ignore_exit=yes;;
+ --comments) comments=yes;;
+ --no-comments) comments=no;;
+ --diag-string) diag_string=$2; shift;;
+ --) shift; break;;
+ -*) usage_error "invalid option: '$1'";;
+ esac
+ shift
+done
+
+test $# -gt 0 || usage_error "missing test command"
+
+case $expect_failure in
+ yes) expect_failure=1;;
+ *) expect_failure=0;;
+esac
+
+if test $color_tests = yes; then
+ red='\e[0;31m' # Red.
+ grn='\e[0;32m' # Green.
+ lgn='\e[1;32m' # Light green.
+ blu='\e[1;34m' # Blue.
+ mgn='\e[0;35m' # Magenta.
+ std='\e[m' # No color.
+else
+ red= grn= lgn= blu= mgn= std=
+fi
+
+# TODO: test script is run here.
+# "$@" | [our magic awk script]
+
+echo "$0: still to be implemented, sorry" >&2
+exit 255
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
# along with this program. If not, see <http://www.gnu.org/licenses/>.
TEST_EXTENSIONS = .test .tap
-TAP_LOG_DRIVER = $(PERL) $(top_srcdir)/lib/tap-driver
+TAP_LOG_DRIVER = $(PERL) $(top_srcdir)/lib/tap-driver.pl
TAP_LOG_DRIVER_FLAGS = --merge
MAINTAINERCLEANFILES =
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
TEST_EXTENSIONS = .test .tap
-TAP_LOG_DRIVER = $(PERL) $(top_srcdir)/lib/tap-driver
+TAP_LOG_DRIVER = $(PERL) $(top_srcdir)/lib/tap-driver.pl
TAP_LOG_DRIVER_FLAGS = --merge
MAINTAINERCLEANFILES = $(parallel_tests) $(instspc_tests)
EXTRA_DIST = ChangeLog-old gen-parallel-tests instspc-tests.sh \
# run with the perl interpreter determined at configure time.
fetch_tap_driver ()
{
- sed "1s|#!.*|#! $PERL -w|" "$top_testsrcdir"/lib/tap-driver >tap-driver \
+ # TODO: we should devise a way to make the shell TAP driver tested also
+ # TODO: with /bin/sh, for better coverage.
+ case $am_tap_implementation in
+ perl)
+ sed "1s|#!.*|#! $PERL -w|" "$top_testsrcdir"/lib/tap-driver.pl ;;
+ shell)
+ sed "1s|#!.*|#! $SHELL|" "$top_testsrcdir"/lib/tap-driver.sh ;;
+ *)
+ fatal_ "invalid \$am_tap_implementation '$am_tap_implementation'" ;;
+ esac > tap-driver \
&& chmod a+x tap-driver \
- || fatal_ "failed to fetch perl tap driver"
+ || framework_failure_ "couldn't fetch $am_tap_implementation TAP driver"
sed 10q tap-driver # For debugging.
}
+# The shell/awk implementation of the TAP driver is still mostly dummy, so
+# use the perl implementation by default for the moment.
+am_tap_implementation=${am_tap_implementation-perl}
## ----------------------------------------------------------- ##
## Checks for required tools, and additional setups (if any) ##
parallel_tests=yes
. ./defs || Exit 1
-fetch_tap_driver
-
cat >> configure.in << END
AC_OUTPUT
END
rm -f *
cat > Makefile.am <<'END'
-TEST_LOG_DRIVER = $(PERL) $(srcdir)/build-aux/tap-driver
+TEST_LOG_DRIVER = $(PERL) $(srcdir)/build-aux/tap-driver.pl
TESTS = foo.test bar.test baz.test
EXTRA_DIST = $(TESTS)
END
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([foreign parallel-tests -Wall -Werror])
AC_CONFIG_FILES([Makefile])
-AC_REQUIRE_AUX_FILE([tap-driver])
+AC_REQUIRE_AUX_FILE([tap-driver.pl])
AC_PATH_PROG([PERL], [perl])
test -n "$PERL" || AC_MSG_ERROR([perl not found])
$PERL -MTAP::Parser -e 1 || AC_MSG_ERROR([TAP::Parser not found])
chmod a+x *.test
mkdir build-aux
-cp "$top_testsrcdir"/lib/tap-driver build-aux
+cp "$top_testsrcdir"/lib/tap-driver.pl build-aux \
+ || framework_failure_ "fetching the perl TAP driver"
(export AUTOMAKE ACLOCAL AUTOCONF && $AUTORECONF -vi) || Exit 1