[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[FYI] {test-protocols} tap: add a dummy TAP driver script implemented in
From: |
Stefano Lattarini |
Subject: |
[FYI] {test-protocols} tap: add a dummy TAP driver script implemented in shell + awk |
Date: |
Wed, 17 Aug 2011 17:48:09 +0200 |
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.
---
ChangeLog | 25 ++++++++
doc/automake.texi | 12 ++--
lib/Makefile.am | 25 ++++++--
lib/Makefile.in | 25 ++++++--
lib/{tap-driver => tap-driver.pl} | 2 +-
lib/tap-driver.sh | 123 +++++++++++++++++++++++++++++++++++++
tests/Makefile.am | 2 +-
tests/Makefile.in | 2 +-
tests/defs | 16 ++++-
tests/tap-common-setup.test | 2 -
tests/tap-doc2.test | 7 +-
11 files changed, 215 insertions(+), 26 deletions(-)
rename lib/{tap-driver => tap-driver.pl} (99%)
create mode 100755 lib/tap-driver.sh
diff --git a/ChangeLog b/ChangeLog
index b64124a..bfd156f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,30 @@
2011-08-17 Stefano Lattarini <address@hidden>
+ 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 <address@hidden>
+
testsuite: refactor tests on TAP support in view of future changes
* tests/defs (fetch_tap_driver): New subroutine; it fetches the
automake-provided TAP driver from the `lib/' directory into the
diff --git a/doc/automake.texi b/doc/automake.texi
index 6be5c2d..ca54999 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -9632,16 +9632,16 @@ use TAP in their testsuite.
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
address@hidden to run your TAP-producing tests. See the example
address@hidden 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.
@@ -9691,14 +9691,14 @@ AC_INIT([GNU Try Tap], [1.0], [bug-automake@@gnu.org])
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)
@@ -9726,7 +9726,7 @@ echo ok 1
# Exit with error, even if all the test case has been successful.
exit 7
-% @kbd{cp @var{PREFIX}/share/address@hidden/tap-driver .}
+% @kbd{cp @var{PREFIX}/share/address@hidden/tap-driver.pl .}
% @kbd{autoreconf -vi && ./configure && make check}
...
PASS: foo.test 1 - Swallows fly
diff --git a/lib/Makefile.am b/lib/Makefile.am
index a9467f1..bc234ee 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -2,8 +2,8 @@
## 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
@@ -27,9 +27,24 @@ dist_pkgvdata_DATA = COPYING INSTALL texinfo.tex ansi2knr.c
ansi2knr.1 \
## _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
diff --git a/lib/Makefile.in b/lib/Makefile.in
index b600402..93b693a 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -15,8 +15,8 @@
@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
@@ -240,9 +240,24 @@ dist_pkgvdata_DATA = COPYING INSTALL texinfo.tex
ansi2knr.c ansi2knr.1 \
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
diff --git a/lib/tap-driver b/lib/tap-driver.pl
similarity index 99%
rename from lib/tap-driver
rename to lib/tap-driver.pl
index 95fb78c..e5a4c6d 100755
--- a/lib/tap-driver
+++ b/lib/tap-driver.pl
@@ -11,7 +11,7 @@ use strict;
use Getopt::Long ();
use TAP::Parser;
-my $ME = "tap-driver";
+my $ME = "tap-driver.pl";
my $USAGE = <<'END';
Usage:
diff --git a/lib/tap-driver.sh b/lib/tap-driver.sh
new file mode 100755
index 0000000..462cf70
--- /dev/null
+++ b/lib/tap-driver.sh
@@ -0,0 +1,123 @@
+#! /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 <address@hidden> or send patches to
+# <address@hidden>.
+
+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='[0;31m' # Red.
+ grn='[0;32m' # Green.
+ lgn='[1;32m' # Light green.
+ blu='[1;34m' # Blue.
+ mgn='[0;35m' # Magenta.
+ std='[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:
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 59a6d14..be61a41 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -17,7 +17,7 @@
# 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 =
diff --git a/tests/Makefile.in b/tests/Makefile.in
index f8e7fe8..5a17514 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -279,7 +279,7 @@ top_build_prefix = @top_build_prefix@
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 \
diff --git a/tests/defs b/tests/defs
index 2b5df6b..4d21a49 100644
--- a/tests/defs
+++ b/tests/defs
@@ -313,11 +313,23 @@ sed_unindent_prog="" # Avoid interferences from the
environment.
# 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) ##
diff --git a/tests/tap-common-setup.test b/tests/tap-common-setup.test
index f97b587..92ae3c4 100755
--- a/tests/tap-common-setup.test
+++ b/tests/tap-common-setup.test
@@ -19,8 +19,6 @@
parallel_tests=yes
. ./defs || Exit 1
-fetch_tap_driver
-
cat >> configure.in << END
AC_OUTPUT
END
diff --git a/tests/tap-doc2.test b/tests/tap-doc2.test
index 63bdc23..1c80294 100755
--- a/tests/tap-doc2.test
+++ b/tests/tap-doc2.test
@@ -27,7 +27,7 @@ test -f ../defs-static && test -f ../defs || Exit 99
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
@@ -37,7 +37,7 @@ AC_INIT([GNU Try Tap], [1.0], address@hidden)
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])
@@ -74,7 +74,8 @@ END
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
--
1.7.2.3