summaryrefslogtreecommitdiff
path: root/tests/tap-diagnostic-custom.test
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2011-08-05 19:08:16 +0200
committerStefano Lattarini <stefano.lattarini@gmail.com>2011-08-05 20:33:47 +0200
commitccf385b973b8eccce6eb38e3b6a35b8b6beded31 (patch)
treef31e197bab43e8180b71e16395f6d08e815785e5 /tests/tap-diagnostic-custom.test
parentcf2e31d3b1f8e7f124c3194417685c0e206fa039 (diff)
downloadautomake-ccf385b973b8eccce6eb38e3b6a35b8b6beded31.tar.gz
tap: new option to change the string designating TAP diagnostic
Here we introduce a new option `--diagnostic-string' in our TAP test driver, that allows the user to specify which string should denote the beginning of a TAP diagnostic line. This change is not gratuitous, nor result if over-engineering: it is motivated by real issues that have emerged during the use of TAP in the Automake's own testsuite (see the commit `v1.11-1082-g9b967c2' "testsuite: yet more use of TAP, and related extensions"). * doc/automake.texi (Use TAP with Automake test harness): Document the new option. (Incompatibilities with other TAP parsers and drivers): Report it as a potential source of incompatibility. * lib/tap-driver ($diag_string): New global variable, defaulting to "#", and whose value can be changed ... (Getopt::Long::GetOptions): ... by the newly recognized option `--diagnostic-string'. (handle_tap_comment): Subroutine removed, some of its simple logic inlined ... (main): ... in here, where now ... (extract_tap_comment): ... this new subroutine is used. ($USAGE): Adjust. * tests/tap-diagnostic.test: Make one check slightly stricter. * tests/tap-diag-custom.test: New test. * tests/Makefile.am (tap_other_tests): Add it.
Diffstat (limited to 'tests/tap-diagnostic-custom.test')
-rwxr-xr-xtests/tap-diagnostic-custom.test96
1 files changed, 96 insertions, 0 deletions
diff --git a/tests/tap-diagnostic-custom.test b/tests/tap-diagnostic-custom.test
new file mode 100755
index 000000000..d96522944
--- /dev/null
+++ b/tests/tap-diagnostic-custom.test
@@ -0,0 +1,96 @@
+#! /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/>.
+
+# TAP support:
+# - option '--diagnostic-string' to customize the string introducing
+# TAP diagnostics
+
+parallel_tests=yes
+. ./defs || Exit 1
+
+cp "$top_testsrcdir"/lib/tap-driver . \
+ || fatal_ "failed to fetch auxiliary script tap-driver"
+
+cat >> configure.in <<END
+AC_SUBST([PERL], ['$PERL'])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+my_log_driver = $(PERL) $(srcdir)/tap-driver
+my_log_compiler = cat
+TEST_EXTENSIONS =
+TESTS =
+END
+
+: > later.mk
+
+# Quoting our comments below is an hack required to keep
+# comments near the things they refer to.
+i=0
+for string in \
+'## A letter' \
+ a \
+'## A number' \
+ 1023 \
+'## A non-alphabetic character' \
+ @ \
+'## Some metacharacters (we need to repeat the "$" for make)' \
+ '^>;&*"|$$' \
+'## A whitespace character' \
+ " " \
+'## A tab character' \
+ "$tab" \
+'## A string with more whitespace' \
+ " ${tab}a b${tab} c" \
+'## Note the we do not have the empty string here. We prefer to' \
+'## leave its behaviour in this context undefined for the moment.'
+do
+ case $string in '##'*) continue;; esac
+ i=`expr $i + 1`
+ unindent >> Makefile.am << END
+ TEST_EXTENSIONS += .t$i
+ TESTS += foo$i.t$i
+ T${i}_LOG_COMPILER = \$(my_log_compiler)
+ T${i}_LOG_DRIVER = \$(my_log_driver)
+ AM_T${i}_LOG_DRIVER_FLAGS = \
+ --comments \
+ --diagnostic-string '$string'
+END
+ unindent > foo$i.t$i <<END
+ 1..1
+ ok 1
+ $string blah blah $i
+END
+ echo "AM_T${i}_LOG_DRIVER_FLAGS = --no-comments" >> later.mk
+done
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=$i pass=$i fail=0 xpass=0 xfail=0 skip=0 error=0
+
+cat later.mk >> Makefile
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+$FGREP 'blah blah' stdout && Exit 1
+
+: