]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
tap: add a dummy TAP driver script implemented in shell + awk
authorStefano Lattarini <stefano.lattarini@gmail.com>
Wed, 17 Aug 2011 12:59:19 +0000 (14:59 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Wed, 17 Aug 2011 14:36:20 +0000 (16:36 +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
doc/automake.texi
lib/Makefile.am
lib/Makefile.in
lib/tap-driver.pl [moved from lib/tap-driver with 99% similarity]
lib/tap-driver.sh [new file with mode: 0755]
tests/Makefile.am
tests/Makefile.in
tests/defs
tests/tap-common-setup.test
tests/tap-doc2.test

index b64124a431f01177285fa3e437b7d9f4d407f0a9..bfd156f1b078e8d3d1a5a1dfa74a0522d9f0eae9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+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
index 6be5c2d6c58cacab41db499f0d61eceee15338a0..ca54999c18c91cf3c12823e72a0ae4ebc6d5cbf5 100644 (file)
@@ -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
-@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.
 
@@ -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/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
index a9467f1f1e677bf59996971194128b39c191dcd1..bc234ee8107a885715cc67b484080eb3d42e73e0 100644 (file)
@@ -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
 
index b60040270ccd4313c851ae46de9ce40c61e78c5d..93b693ac828937d27998aa3f805a3a083a5f7fd4 100644 (file)
@@ -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
similarity index 99%
rename from lib/tap-driver
rename to lib/tap-driver.pl
index 95fb78ce79ef0fa834522bd9101f4d720edddccb..e5a4c6dad8812fac73fb46dab1fc5a75dbd1af22 100755 (executable)
@@ -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 (executable)
index 0000000..462cf70
--- /dev/null
@@ -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 <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:
index 59a6d142a8e1efc292fa96c5f506ac5d5b33d62d..be61a412ca06e8ed2d7566ea7519994ba6684f01 100644 (file)
@@ -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 =
index f8e7fe87ed537ec0f576deffdcd0d69ef48e5070..5a1751478d9cd47790b106d30e8e73edf506d19d 100644 (file)
@@ -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 \
index 2b5df6b0aa050b1ac1a632a86eda219287178297..4d21a49f077b3ef1498a0505ea145982e5e24e5d 100644 (file)
@@ -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)  ##
index f97b5876d54f3ebf417283fc390ffd99c4b07b2b..92ae3c45229dad2c9aaf7bad7db4f37b7cf413cf 100755 (executable)
@@ -19,8 +19,6 @@
 parallel_tests=yes
 . ./defs || Exit 1
 
-fetch_tap_driver
-
 cat >> configure.in << END
 AC_OUTPUT
 END
index 63bdc23eb7ff8a9e0dddd352091a17b462a48a98..1c80294bb07baa7967f3e78f5d4f8d05fdf5f54e 100755 (executable)
@@ -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], [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])
@@ -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