summaryrefslogtreecommitdiff
path: root/lib/tap-driver.sh
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2011-08-17 14:59:19 +0200
committerStefano Lattarini <stefano.lattarini@gmail.com>2011-08-17 16:36:20 +0200
commit51f413e99a4254139b40294bc808d614b755a35b (patch)
tree038a730ac15ee879d28a4232fbbe0f62d6c4683e /lib/tap-driver.sh
parentfb21ed841b61c61d70ac9c370f53d2cf53231764 (diff)
downloadautomake-51f413e99a4254139b40294bc808d614b755a35b.tar.gz
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.
Diffstat (limited to 'lib/tap-driver.sh')
-rwxr-xr-xlib/tap-driver.sh123
1 files changed, 123 insertions, 0 deletions
diff --git a/lib/tap-driver.sh b/lib/tap-driver.sh
new file mode 100755
index 000000000..462cf70f6
--- /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 <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='' # Red.
+ grn='' # Green.
+ lgn='' # Light green.
+ blu='' # Blue.
+ mgn='' # Magenta.
+ std='' # 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: